在Magento中找到使用优惠券代码的非会员的姓名和电子邮件地址 [英] Find the name and email address of non-members who used coupon code in Magento
问题描述
我们希望能够提取以客人身份购买商品的顾客的姓名和电子邮件地址.有人有运气吗?
We would like to be able to pull the name and email address of customers who purchased items as a guest. Has anyone had any luck in doing so?
我看过几篇关于如何提取使用优惠券代码的客户名称的文章,但关于非客户却一无所获!
I've seen a few posts of how to pull the names of customers who have used the coupon code, but nothing about non-customers!
非常感谢你们的帮助!
-杰夫
推荐答案
这应该有效:
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToSelect('customer_firstname')
->addAttributeToSelect('customer_lastname')
->addAttributeToSelect('customer_email')
->addAttributeToSelect('customer_group_id')
->addAttributeToFilter('customer_group_id', Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
;
然后可以通过遍历集合来访问值...
You can then access the values by iterating over the collection...
foreach($orderCollection as $order) {
$customerFirstname = $order->getData('customer_firstname');
$customerLastname = $order->getData('customer_lastname');
$customerEmail = $order->getData('customer_email');
//Do what you want with the values here
}
上面的代码回答了问题的第一段.第二段建议您正在寻找与众不同的东西.您是否在寻找使用了特定优惠券代码的访客客户?如果是这样,那么您应该像这样加载集合:
The above code answers the first paragraph of your question. The second paragraph suggests you are looking for something different though. Are you looking for guest customers who have used a particular coupon code? If so then you should load the collection like this:
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToSelect('customer_firstname')
->addAttributeToSelect('customer_lastname')
->addAttributeToSelect('customer_email')
->addAttributeToSelect('customer_group_id')
->addAttributeToSelect('coupon_code')
->addAttributeToFilter('customer_group_id', Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
->addAttributeToFilter('coupon_code', 'your_awesome_coupon_code')
;
这篇关于在Magento中找到使用优惠券代码的非会员的姓名和电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!