2017-01-17 102 views
0

我使用此代碼獲取所有廢棄的購物車。如何過濾magento廢棄的購物車報告集合

$storeIds = array(1); 
    $collection = Mage::getResourceModel('reports/quote_collection'); 
    $collection->prepareForAbandonedReport($storeIds); 
    $collection->load(); 

我想的是,拿到車並不比一些具體的日期之前,我也曾嘗試下面的代碼來實現它,但它不工作。

$collection->addFieldToFilter(array("main_table.created_at"=>Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-1 week')))); 

)另一件事,我怎麼能addAttributeToselect(獲得所需要的數據,而不是所有。如果有人還可以提供一些其他過濾器示例答案會很grateful.Thanks提前

回答

0

因此,經過大量的搜索,我終於找到了辦法。函數prepareForAbandonedReport()完成所有的過濾步驟,所以我打開包含這個函數的文件,複製它的代碼並將其用在我的代碼中,並根據我的需要進行更改。這裏是我使用的代碼,我希望這會幫助別人。

 $collection = Mage::getResourceModel('reports/quote_collection') 
     ->addFieldToFilter('items_count', array('neq' => '0')) 
     ->addFieldToFilter('main_table.is_active', '1') 
     ->addFieldToFilter('main_table.created_at', array('gt' => date("Y-m-d H:i:s", strtotime('-2 month')))) 
     ->addSubtotal($storeIds, null) 
     ->addCustomerData(null) 
     ->setOrder('updated_at') 
     ->addFieldToFilter('store_id', array('in' => $storeIds)); 
    $collection->load(); 
0

請使用下面的代碼,這可能會有所幫助 -

$collection = Mage::getResourceModel('reports/quote_collection'); 
$collection->prepareForAbandonedReport(); 
$output = $collection->load()->toArray(); 
+0

請準備好實際的要求,我已經從我提供的代碼中獲得了廢棄的購物車數據,我希望根據我的需要過濾收集的數據。 –