gpt4 book ai didi

php - 基于类别的时事通讯电子邮件? Magento CE 1/6/2

转载 作者:行者123 更新时间:2023-11-29 05:31:55 25 4
gpt4 key购买 nike

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

最佳答案

这是一种解决方法:

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

希望对你有帮助

关于php - 基于类别的时事通讯电子邮件? Magento CE 1/6/2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13974988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com