I am working outside of magento store root folder (1.4) and I would like to get customers order totals, and date of last order. I have started with this:
$customer = Mage::getModel('customer/customer')->load($entity_id);
$customerTotals =Mage::getResourceModel('sales/sale_collection')
->setCustomerFilter($customer)
->load()
->getTotals();
echo $customerTotals->getNumOrders();
echo money_format('$%i',$customerTotals->getLifetime());
This seems to be giving me totals from the wrong customer… Also, can’t quite figure out how to get customers last order day.
any help would be appreciated.
This will work, giving you the total number of order, total sales and most recent order for a given customer.
The code could be shortened a little, but for clarity it is as follows…