I would like to add column to the backend order grid.
I then followed this tutorial : Tuto
on this model, I then tried to add a second column : the client company
I tried :
<?php
class Mine_Ordergridmodule_Model_Observer
{
public function salesOrderGridCollectionLoadBefore($observer)
{
$collection = $observer->getOrderGridCollection();
$select = $collection->getSelect();
$select->joinLeft(array('payment'=>$collection->getTable('sales/order_payment')), 'payment.parent_id=main_table.entity_id',array('payment_method'=>'method'));
//$select->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id',array('company_name'=>'company'));
$select->joinLeft(array('company'=>$collection->getTable('sales_flat_order_address')), 'company.parent_id=main_table.entity_id',array('company_name'=>'company'));
}
}
and in my layout xml :
<layout>
<sales_order_grid_update_handle>
<reference name="sales_order.grid">
<action method="addColumnAfter">
<columnId>payment_method</columnId>
<arguments>
<header>Payment Method</header>
<index>payment_method</index>
<filter_index>payment.method</filter_index>
<type>text</type>
</arguments>
<after>grand_total</after>
</action>
<action method="addColumnAfter">
<columnId>company</columnId>
<arguments>
<header>Company</header>
<index>company</index>
<type>text</type>
</arguments>
<after>shipping_name</after>
</action>
</reference>
</sales_order_grid_update_handle>
<adminhtml_sales_order_grid>
<!-- apply layout handle defined above -->
<update handle="sales_order_grid_update_handle" />
</adminhtml_sales_order_grid>
<adminhtml_sales_order_index>
<!-- apply layout handle defined above -->
<update handle="sales_order_grid_update_handle" />
</adminhtml_sales_order_index>
</layout>
but it is not working...