2013-07-04 60 views
0

我确实需要检查特定客户在购物车中购买哪些产品(或者只有有的话)。Magento 1.7 - 为特定客户获取购物车物品

我想要创建一个cron任务来检查客户是否打开购物车比例如2天更早,然后向他发送带有提醒消息的邮件。我有一个客户阵列:

$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*'); 
$customers = array(); 
foreach ($collection as $customer) { 
    $customers[] = $customer->toArray(); 

但两天我找不到方法来检查他们每个的购物车项目。 我想:

foreach ($customers as $item) { 

    $quote = Mage::getModel('sales/quote')->loadByCustomer($item['entity_id']); 

    if ($quote) { 
     $collection = $quote->getItemsCollection(false); 
    } 
    else { 
     echo '<script type="text/javascript">alert("test")</script>'; 
    } 
    print_r($collection); 
    foreach ($collection as $tmp) 
     echo $tmp->getQty(); 
} 

我想也更多,但没有工作对我来说:/ 我也不知道如何打印归还物品时,阵列中的每个字段被保护。

请帮助,如果你可以或者你只想到你可以;)谷歌没有帮助它。 谢谢

回答

0

我相信你正在使用Magento社区,因为企业已经有一个废弃的购物车提醒。如果您有权访问Enterprise,您可以在此处找到代码:Enterprise_Reminder_Model_Rule_Condition_Cart :: _ prepareConditionsSql($ customer,$ website) 此方法使用magento资源读取适配器创建原始sql,并添加不同的条件以验证购物车是否已放弃见下面的一些人(不要忘记检查quote.updated_at)

$select = $this->getResource()->createSelect(); 
$select->from(array('quote' => $table), array(new Zend_Db_Expr(1))); 
... 
$select->where('quote.is_active = 1'); 
$select->where($this->_createCustomerFilter($customer, 'quote.customer_id')); 
... 

我希望这有助于摘录给你一个开始,我不知道我是否可以从企业在这里发布的代码。

+0

非常感谢我无法访问magento enterprice,但是当您将其称为“废弃购物车提醒”时,我寻找了一些插件,我认为它找到了。 我必须尝试一下,但非常感谢。 –

相关问题