你這是怎麼弄的壽命銷售:
$customer = Mage::getModel('customer/customer')->load($customerId);
$customerTotals = Mage::getResourceModel('sales/sale_collection')
->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true)
->setCustomerFilter($customer)
->load()
->getTotals();
$customerLifetimeSales = $customerTotals->getLifetime();
$customerNumberOfOrders = $customerTotals->getNumOrders();
這是$ customerTotals一個的var_dump:
object(Varien_Object)[662]
protected '_data' =>
array
'lifetime' => float 10503.13
'base_lifetime' => float 10503.13
'base_avgsale' => float 92.9480530973
'num_orders' => int 113
'avgsale' => float 92.9480530973
protected '_hasDataChanges' => boolean false
protected '_origData' => null
protected '_idFieldName' => null
protected '_isDeleted' => boolean false
您可以將這些代碼在你的塊上的方法,並調用它每一行。財產以後這樣的:
public function getCustomerTotals(Mage_Customer_Model_Customer $customer)
{
// TODO: Add necessary validation...
return Mage::getResourceModel('sales/sale_collection')
->setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELED, true)
->setCustomerFilter($customer)
->load()
->getTotals();
}
,並在你的代碼中有你可以添加:
<?php $customerTotals = $this->getCustomerTotals($customer); ?>
<td><?php echo $customerTotals->getLifetime(); ?></td>
我將不得不給這個很快!這個'項目'現在已經進入了後退階段,但如果這項工作成功的話,那麼這是一個不得名單! – Geoff
我終於在一個模塊中使用它,將它添加到訂單概覽頁面(稍作修改)。謝謝! – Geoff