I'm trying to add Billing Company and Shipping Company to the Sales Order Grid (Magento CE 1.9.0.1) but everything I have tried appears to have no effect - I don't even see the new column with empty data and there's nothing in the log to suggest what's wrong either. Wondered if someone might be able to help?
I'm duplicating this file: /app/code/core/Mage/Adminhtml/Block/Sales/order/Grid.php as /app/code/local/Mage/Adminhtml/Block/Sales/order/Grid.php and then modifying as follows;
(_prepareCollection and _prepareColumns stripped back to simply show the new code)
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
//New line
$collection->getSelect()->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id' ,array('company'=> 'company' ));
$collection->addFieldToFilter('sales_flat_order_address.address_type', array('eq' => 'billing'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
[...]
$this->addColumn('company', array(
'header' => Mage::helper('sales')->__('Billing Company'),
'index' => 'company',
));
[...]
}