Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created January 26, 2012 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlamanna/1680842 to your computer and use it in GitHub Desktop.
Save danlamanna/1680842 to your computer and use it in GitHub Desktop.
Adding customer attributes to Magento Adminhtml Order Grid.
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft(array('sfoa'=>'sales_flat_order_address'),'sfoa.entity_id=main_table.entity_id',array('sfoa.postcode'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('postcode', array(
'header' => 'Customer Zip',
'width' => '80px',
'type' => 'text',
'index' => 'postcode',
'filter_index' => 'sfoa.postcode'));
$this->addColumn('real_order_id', array(
'header'=> Mage::helper('sales')->__('Order #'),
'width' => '80px',
'type' => 'text',
'index' => 'increment_id',
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment