Try the Demo

Magento Forum

   
How do I add another attribute to order_aggregated_created table? 
 
cismerc
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2012-10-04
 

I’ve been scratching my head for days on this one. Any help or a push in the right direction would be greatly appreciated.

I’ve extended the sales report under Reports->Sales->Orders and created my own custom filters to filer the report by channels.
Each order has a ‘channel_name’ attribute to identify whether the order came from eBay, Amazon, etc.

Now I cannot for the life of me figure out how sales/order_aggregated_created table that is used to generate the reports is created. Where does the magic happen? I want to add ‘channel_name’ to the order_aggregated_created table to be able to filter by this attribute, but I cannot figure out how to this.

Diagram for order_aggregated_created table with its attributes:
http://www.magento-exchange.com/wp-content/uploads/2010/11/MAGENTO-SALES-ORDER-ER.png

Mage_Sales_Model_Resource_Report_Order_Collection is where the magic starts in retrieving the sales totals, particularly if I understood this correctly inside

protected function _getSelectedColumns(){...}

        
if (!$this->isTotals()) {
            $this
->_selectedColumns = array(
                
'period'                         => $this->_periodFormat,
                
'orders_count'                   => 'SUM(orders_count)',
                
'total_qty_ordered'              => 'SUM(total_qty_ordered)',
                
'total_qty_invoiced'             => 'SUM(total_qty_invoiced)',
                
'total_income_amount'            => 'SUM(total_income_amount)',
                
'total_revenue_amount'           => 'SUM(total_revenue_amount)',
                
'total_profit_amount'            => 'SUM(total_profit_amount)',
                
'total_invoiced_amount'          => 'SUM(total_invoiced_amount)',
                
'total_canceled_amount'          => 'SUM(total_canceled_amount)',
                
'total_paid_amount'              => 'SUM(total_paid_amount)',
                
'total_refunded_amount'          => 'SUM(total_refunded_amount)',
                
'total_tax_amount'               => 'SUM(total_tax_amount)',
                
'total_tax_amount_actual'        => 'SUM(total_tax_amount_actual)',
                
'total_shipping_amount'          => 'SUM(total_shipping_amount)',
                
'total_shipping_amount_actual'   => 'SUM(total_shipping_amount_actual)',
                
'total_discount_amount'          => 'SUM(total_discount_amount)',
                
'total_discount_amount_actual'   => 'SUM(total_discount_amount_actual)',
            );
        
}

If would be awesome if I can just ‘channel_name’ =>$this->_channelName, and be on my merry way.

 Signature 

You ever have that feeling… where you’re not sure if you’re awake or still dreaming?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top