如何向order_aggregated_created表添加另一个属性?

时间:2013-01-05 23:44:05

标签: php mysql magento

我在这个问题上已经好几天了。任何帮助或推动正确的方向将不胜感激。

我已在Reports-> Sales-> Orders下扩展了销售报告,并创建了我自己的自定义过滤器,以按渠道提交报告。 每个订单都有一个'channel_name'属性,用于标识订单是来自eBay,Amazon等。

现在我不能为我的生活弄清楚如何创建用于生成报告的sales / order_aggregated_created表。魔法在哪里发生?我想将'channel_name'添加到order_aggregated_created表中,以便能够按此属性进行过滤,但我无法弄清楚如何做到这一点。

order_aggregated_created表及其属性的图表: http://www.magento-exchange.com/wp-content/uploads/2010/11/MAGENTO-SALES-ORDER-ER.png

Mage_Sales_Model_Resource_Report_Order_Collection是魔术开始检索销售总额的地方,特别是如果我在内部正确理解了这一点

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)',
            );
        }

如果我可以'channel_name'=> $ this-> _channelName,那就太棒了,并且是我的快乐方式。

1 个答案:

答案 0 :(得分:2)

经过大量研究后发现,sales / order_aggregated_created表在这里生成:

Mage_Sales_Model_Resource_Report_Order_Createdat

现在我看过这里似乎正是我所需要的,但我所做的任何改变都不会反映在Magento报告中,特别是在sales / order_aggregated_created表中。

我发现Mage_Sales_Model_Resource_Report_Order_Createdat仅在您刷新Reports-> Sales-> Orders中的统计信息时被调用,然后才会生成新的sales / order_aggregated_created表!因此,对于希望通过自定义属性过滤订单销售报告的任何人,请查看内部:/app/code/core/Mage/Sales/Model/Resource/Report/Order/Createat.php