我使用Magento市場細分插件,並且我試圖分割不僅具有訂單狀態「已完成」但「已完成」和「正在處理」的用戶。獲取狀態爲「已完成」AND「處理」的訂單數
的細分根據客戶的原代碼部分如下所示:
if ($this->getAttribute() == 'ordered') {
$customersOrders = Mage::helper('marketsuite/customer')->getOrderCollectionByCustomerIds($_customerIds);
$customersOrders->addFieldToFilter('state', Mage_Sales_Model_Order::STATE_COMPLETE);
$_arrayOrderIdCustomerId = $customersOrders->getConnection()->fetchPairs($customersOrders->getSelect());
$_arrayOrderIdTotal = $this->_getValidatedTotalOrderedCount(array_keys($_arrayOrderIdCustomerId));
$_validatedArrayOrderIdCustomerId = array_intersect_key($_arrayOrderIdCustomerId, $_arrayOrderIdTotal);
另一部分用於segmentating基於訂單:
public function validateOrderCollection(Zend_Db_Select $select)
{
if ($this->getAttribute() == 'ordered') {
$select
->where('state = ?', Mage_Sales_Model_Order::STATE_COMPLETE)
;
$_orderIds = Mage::helper('marketsuite/order')->getAllIds($select);
$orderTotals = $this->_getValidatedTotalOrderedCount($_orderIds);
$validatedOrders = array();
foreach ($orderTotals as $orderId => $totalOrderedCount) {
if ($this->validateAttribute($totalOrderedCount)) {
array_push($validatedOrders, $orderId);
}
}
return $validatedOrders;
}
return array();
}
問題:如何既包括「完成」和在這兩種情況下「處理」訂單。我知道它與這部分$customersOrders->addFieldToFilter('state', Mage_Sales_Model_Order::STATE_COMPLETE);
有關,但我不完全確定如何實現這一點。
非常感謝您的幫助。
感謝這樣的代碼,但實際上我真的不知道在哪裏把它在我的例子張貼在上面。 –