Reputation: 11
I Magento, when you go to Customers -> Manage Customers and you are on the list of all customers, my client wants to add "Lifetime Sales" to this report. Is this possible ?
Thanks, Mark
Upvotes: 0
Views: 1037
Reputation: 2931
It's not that hard to do it. You need to extend that grid. I recently needed something similar so here is my query to get lifetime sales.
$orderStatuses = array(Mage_Sales_Model_Order::STATE_COMPLETE, Mage_Sales_Model_ORder::STATE_PROCESSING);
$order = Mage::getModel('sales/order');
$resourceOrder = $order->getResource();
$select = $readConnection->select()
->from(array('sales' => $resourceOrder->getTable('sales/order')), 'SUM(base_subtotal)')
->where('sales.customer_id=?', $customer->getId())
;
//filter by status
$select->where('state IN (?)', $orderStatuses);
// echo $select . '<br/>'; exit;
$total = $readConnection->fetchOne($select);
You can change orderStatuses array and add whatever suits you.
Upvotes: 0
Reputation: 37700
There is already something similar in Reports > Customers > Customers by orders total.
Note that reports tend to take a long time to render because they are collating a lot of information, the Manage-* pages need to be kept light so I wouldn't like the thought of shoe-horning too much information into those tables. If the Customers by orders total report isn't quite right then consider writing a new report - in the reports section - that is better suited.
Upvotes: 2