Magento:订购特定商品时发送通知

Magento:订购特定商品时发送通知,magento,Magento,我们一直在使用第三方来包装和运送我们的包裹。因此,我们不再看到所有的订单 但有几种产品是我们自己手工提供的,比如数码礼品卡。当客户订购特定SKU时,是否有可能让Magento向我们发送电子邮件?例如,通知我们需要为客户创建礼品卡 我不想看到我们邮箱中的每个订单,只想看到一些特定的SKU 谢谢, Menno是这可以通过自定义模块实现。创建您的模块并向其config.xml中添加事件观察者 <events> <checkout_onepage_controller_

我们一直在使用第三方来包装和运送我们的包裹。因此,我们不再看到所有的订单

但有几种产品是我们自己手工提供的,比如数码礼品卡。当客户订购特定SKU时,是否有可能让Magento向我们发送电子邮件?例如,通知我们需要为客户创建礼品卡

我不想看到我们邮箱中的每个订单,只想看到一些特定的SKU

谢谢,
Menno

是这可以通过自定义模块实现。创建您的模块并向其config.xml中添加事件观察者

<events>
        <checkout_onepage_controller_success_action>
            <observers>
                <copymein>
                    <type>singleton</type>
                    <class>dispatcher/observer</class>
                    <method>ccMyEmail</method>
                </copymein>
            </observers>
        </checkout_onepage_controller_success_action>
    </events>

需要注意的是,创建一个在前端不可见的产品属性会更有效,该属性定义产品是否需要您的关注,即需要关注的内容。\u注意是/否,然后扫描订购的产品以查找该属性中的“是”值。比硬编码您正在寻找的SKU更易于管理;)

您可以为此功能创建自定义模块。因此,在新模块中,您必须钩住观察者事件:checkout\u onepage\u controller\u success\u action。 您可以执行以下操作:

       <checkout_onepage_controller_success_action>
            <observers>
               <xxx_checkout_success>
                   <type>singleton</type>
                   <class>[Your Module Name]/observer</class>
                   <method>sendEmailToCustomerForSales</method>
               </xxx_checkout_success>
            </observers>
        </checkout_onepage_controller_success_action>

这似乎是一个很好的解决方案。我以前没有为Magento创建自定义模块,但希望会有一些好的教程。在使用自定义属性时,有没有想过如何更改上述代码?这似乎是最好的选择。真的很高兴它起到了作用。使用自定义属性,而不是:if($product->getSku()=('123'| |'234'| |'345')){///这样做;$attrValue=$product->getResource()->getAttribute('your_attr_code')->getFrontend()->getValue($product);if($attrValue='Yes'){///
       <checkout_onepage_controller_success_action>
            <observers>
               <xxx_checkout_success>
                   <type>singleton</type>
                   <class>[Your Module Name]/observer</class>
                   <method>sendEmailToCustomerForSales</method>
               </xxx_checkout_success>
            </observers>
        </checkout_onepage_controller_success_action>
public function sendEmailToCustomerForSales($observer) {
    $orderId = (int)current($observer->getEvent()->getOrderIds());
    $order = Mage::getModel('sales/order')->load($orderId);
    $itemCollection = $order->getItemsCollection();
    foreach($itemCollection as $item) {
        $_product = Mage::getModel('catalog/product')->load($item->getProductId());
        if($_product->getSku() == '[Your specific sku]') {
            /*send an email to the customer*/
        }
    }
}