How do i get the amount (sales since the beginning) displayed in when we go to the customer edit page in the admin section?

I tried getting the amount using :

$total = 0;
$collectionOrders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('status', array('in'=>array('complete','on hold')));

foreach($collectionOrders as $order){
    $total += $order->getGrandTotal();
echo $total."\n";

But the total I get is lower.


Are you using multiple Currencies in your Stores? I suggest using $total += $order->getBaseGrandTotal(); to make sure everything is calculated in your Base Currency.

You might also want to check your Tax Settings, maybe your GrandTotal is not including some Tax or other Fee you add to your Order

  • No i'm not using multiple currencies. – mockingbid Apr 12 '16 at 9:36
  • Could you provide some more Information on what you expect to happen and what happens? Especially what is the $total you expect and what are the totals of the orders you use to calculate? - edit: by "the totals of the orders" I mean baseSubtotal, BaseTaxAmout, BaseDiscountAmount, BaseShipping... – mybinaryromance Apr 12 '16 at 9:43
  • I got it now. Apparently magento calculates the total amount of purchases based in all orders expect cancelled ones so when i filter only by complete orders i got a lower number. – mockingbid Apr 12 '16 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.