繁体   English   中英

基于类别的简报电子邮件? Magento CE 1/6/2

[英]Category based newsletter emails? Magento CE 1/6/2

有没有人知道我如何根据他们订购的类别向客户发送新闻通讯电子邮件? 因此,例如,我想每月向购买了考试手套的客户发送电子邮件,以补充其供应。

这是一种方法:

1)获得所有(最近的)订单

 $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', '2012-04-16 15:56:33');

注意:使用正确的日期和时间戳替换'2012-04-16 15:56:33'

2)订购产品

foreach($orders as $order):
    // let's get some the order info
    $orderData = $order->getData();
    // extract the order ID from the order objecj (so we can load the whole order)
    $orderId = $orderData['entity_id'];
    // extract the customer's ID (so that we can find out customer's email)
    $customerId = $orderData['customer_id'];
    // load the customer by ID
    $customer = Mage::getModel('customer/address')->load($customerId)->getData();
    // get customer's email address
    $customerEmail = $customer['email'];
    // load the full order (so that we can get a list of product's ordered
    $fullOrder = Mage::getModel('sales/order')->load($orderId);
    // extract the products from the order
    $products = $fullOrder->getAllItems();
endforeach;

3)找出产品的类别

foreach ($products as $product):
    // let's get an object with the ordered product's data
    $productInfo = $product->getData();
    // extract the product ID (so that we can load the product)
    $prodId = $productInfo['item_id'];
    // load the product
    $product = Mage::getModel('catalog/product')->load($prodId);
    // get all (names of) categories that this product is associated with
    $categories = $product->getCategoryCollection()->addAttributeToSelect('name');
endforeach;

4)向这些客户发送特定模板(请参阅此问题的第一个答案中的代码)以编程方式在Magento中发送电子邮件失败

希望这有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM