2013-07-04 59 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,但是當您將其稱爲「廢棄購物車提醒」時,我尋找了一些插件,我認爲它找到了。 我必須嘗試一下,但非常感謝。 –

相關問題