Php 基于类别的时事通讯电子邮件?Magento CE 1/6/2
有人知道我如何根据客户的订购类别向他们发送时事通讯电子邮件吗?例如,我想每月向购买检查手套的客户发送一封电子邮件,以补充供应。这里有一种方法: 1) 获取所有(最近)订单 注:用正确的日期和时间戳替换Php 基于类别的时事通讯电子邮件?Magento CE 1/6/2,php,mysql,magento,magento-1.6,Php,Mysql,Magento,Magento 1.6,有人知道我如何根据客户的订购类别向他们发送时事通讯电子邮件吗?例如,我想每月向购买检查手套的客户发送一封电子邮件,以补充供应。这里有一种方法: 1) 获取所有(最近)订单 注:用正确的日期和时间戳替换'2012-04-16 15:56:33' 2) 订购产品 foreach($orders as $order): // let's get some the order info $orderData = $order->getData(); // extract t
'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) 向这些客户发送特定模板(请参见此问题第一个答案中的代码)
希望这是有帮助的或者如果根据从中订购的类别导出客户姓名/电子邮件地址列表的工作量太大。我知道它是在数据库中导出的…您可以编写一个查询,从数据库中提取数据。将产品与订单项目和订单信息链接。
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;