【问题标题】:Category based newsletter emails? Magento CE 1/6/2基于类别的时事通讯电子邮件? Magento CE 1/6/2
【发布时间】:2012-12-20 15:04:57
【问题描述】:

有没有人知道如何根据客户订购的类别向他们发送简报电子邮件?例如,我想每月向购买了检查手套的客户发送一封电子邮件,以补充他们的供应。

【问题讨论】:

  • 或者如果工作量太大,至少要根据订购的类别导出客户姓名/电子邮件地址列表。我知道它在数据库中导出...
  • 您可以编写一个从数据库中提取数据的查询。将产品与 order-items 和 order-info 链接。

标签: php mysql magento magento-1.6


【解决方案1】:

这是一种解决方法:

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) 向这些客户发送特定模板(参见本问题第一个答案中的代码)Sending e-mail programmatically in Magento is failing

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2015-08-06
    • 1970-01-01
    • 2014-03-19
    • 2013-01-29
    • 2014-06-26
    • 1970-01-01
    • 1970-01-01
    • 2015-05-20
    • 1970-01-01
    相关资源
    最近更新 更多