简体   繁体   English

Magento 1.9.2管理员在“按订单数”报告中的“客户”中添加街道列

[英]Magento 1.9.2 admin add street column in Customers by number of orders report

I want to add street column in admin->report->Customers by number of orders.(Magento 1.9.2) 我想按订单数在admin-> report-> Customers中添加街道列。(Magento 1.9.2)

I have tried adding join query in 'app\\code\\core\\Mage\\Reports\\Model\\Resource\\Customer\\Orders\\Collection.php' 我尝试在'app \\ code \\ core \\ Mage \\ Reports \\ Model \\ Resource \\ Customer \\ Orders \\ Collection.php'中添加联接查询

protected function _joinFields($from = '', $to = '')
{   

    $this->joinCustomerName()
        ->groupByCustomer()
        ->addOrdersCount()                 
        ->addAttributeToFilter('main_table.created_at', array('from' => $from, 'to' => $to, 'datetime' => true))
        ->join(array('p' => 'sales/order_address'), 'main_table.entity_id = p.parent_id', array(
                'street'
        ));

        return $this;
}

And in 'app\\code\\core\\Mage\\Adminhtml\\Block\\Report\\Customer\\Orders\\Grid.php' 并在'app \\ code \\ core \\ Mage \\ Adminhtml \\ Block \\ Report \\ Customer \\ Orders \\ Grid.php'中

$this->addColumn('street', array(
        'header'    => $this->__('street'),
        'sortable'  => false,
        'index'     => 'street'
    ));

I am getting the main table data but not the fields I have joined. 我正在获取主表数据,而不是我已加入的字段。

I have tried this, any other method is always welcome. 我已经尝试过了,任何其他方法总是很受欢迎。 Thanks in advanced. 提前致谢。

在此处输入图片说明

In 'app\\code\\core\\Mage\\Adminhtml\\Block\\Report\\Customer\\Orders\\Grid.php' You have to include renderer tag that will fetch the data from the respective module. 在“ app \\ code \\ core \\ Mage \\ Adminhtml \\ Block \\ Report \\ Customer \\ Orders \\ Grid.php”中,您必须包括renderer标签,该标签将从相应模块中获取数据。

$this->addColumn('street', array(
    'header'    => $this->__('street'),
    'sortable'  => false,
    'index'     => 'street',
    'renderer'  => 'namespace_module/adminhtml_module_renderer_streetname',

));

You have to include a method inside the renderer path that will return the street name. 您必须在渲染器路径中包括一个将返回街道名称的方法。 That's it 而已

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM