0
votes

I want to add street column in admin->report->Customers by number of orders.(Magento 1.9.2)

I have tried adding join query in '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'

$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.

enter image description here

1
Are you looking for the data inside the street column ? - biplab rout
Yes, in this scenario i am joining sales_flat_order(main_table) and sales_flat_order_address. Getting data from sales_flat_order(main_table) but not getting the data from sales_flat_order_address - Manish Rane

1 Answers

0
votes

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.

$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