I have added "Company" field in admin customer grid, but the issue i face is sorting not working.
I have override Mage_Adminhtml_Block_Customer_Grid Class and added below code:
protected function _prepareCollection()
{
parent::_prepareCollection();
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->addAttributeToSelect('company')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
$this->setCollection($collection);
return $this;
}
protected function _prepareColumns()
{
$this->addColumn('company', array(
'header' => Mage::helper('customer')->__('Company'),
'width' => '150',
'index' => 'billing_company',
));
$this->addColumnsOrder('billing_company', 'email');
return parent::_prepareColumns();
}
Can anyone have solution for above issue?