I am trying to extend the Mage_Adminhtml_Block_Sales_Order_Grid to add a new column.
I have a populated field in the 'sales_flat_order' table (order_ready_for_dispatch) that I wish to show in the grid (this field is added/updated separately).
The issue is the data is not showing in that column with the following code:
/app/code/local/Sulman/SalesGrid/etc/config.xml
<?xml version="1.0"?>
<config>
<global>
<modules>
<Sulman_SalesGrid>
<version>1.0.0</version>
</Sulman_SalesGrid>
</modules>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>Sulman_SalesGrid_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
app/code/local/Sulman/SalesGrid/Block/Adminhtml/Sales/Order/Grid.php
<?php
class Sulman_SalesGrid_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
protected function _prepareCollection() {
$collection = parent::_prepareCollection()->getCollection();
$collection->addFieldToSelect('order_ready_for_dispatch');
return $this;
}
protected function _prepareColumns()
{
$this->addColumn('order_ready_for_dispatch', array(
'header'=> Mage::helper('sales')->__('Despatch Date'),
'width' => '80px',
'type' => 'text',
'index' => 'order_ready_for_dispatch',
));
return parent::_prepareColumns();
}
}
Can anyone see my mistake? Thanks :)