I need to get the sales revenue per product using sales order.
I have been using product_collection
to multiply FinalPrice
with order_qty
But as the FinalPrice
changes, this is no good to work out the actual sales revenue.
I can get the revenue for all products but I cannot seem to filter by Product ID.
$revenue = Mage::getModel( 'sales/order' )->getCollection()
->addAttributeToSelect('grand_total')
->getColumnValues('grand_total');
$overall_profit = array_sum( $revenue );
$overall_profit = Mage::helper( 'core' )->currency( $overall_profit, true, false );
I am using this inside a loop so I have access to Product_ID
, SKU
etc
Best Answer
Based on your own answer, you can do it using Magento objects as Julien suggested: