I had override _prepareCollection() method of Mage_Adminhtml_Block_Customer_Grid and added following lines



protected function _prepareCollection()
    $collection = Mage::getResourceModel('customer/customer_collection')
                ->addAttributeToSelect('cus_city') // added 
                ->addAttributeToSelect('cus_country') // added 
                ->addAttributeToSelect('cus_state') // added 
                ->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_country_id', 'customer_address/country_id', 'default_billing', null, 'left');

    return parent::_prepareCollection();

and add these 3 columns in the _prepareColumns() as follows

$this->addColumn('cus_city', array(
    'header'    => Mage::helper('customer')->__('City'),
    'width'     => '100',
    'index'     => 'cus_city'

$this->addColumn('cus_country', array(
    'header'    => Mage::helper('customer')->__('Country'),
    'width'     => '100',
    'index'     => 'cus_country'

$statearray = Mage::getModel('directory/region')->getResourceCollection() ->addCountryFilter('IN')->load()->toOptionArray();
foreach($statearray as $states){
    $data_array[$states['value']] = $states['label'];

$this->addColumn('cus_state', array(
    'header'    => Mage::helper('customer')->__('State'),
    'width'     => '100',
    'type'   => 'options',
    'index'     => 'cus_state',
    'options' => $data_array,

Issue is this 3 columns are not populating with the data when it is in the overriden module and if i add same code in the core this 3 columns are populating with the values

1 Answer 1


In the end you call the original method with return parent::_prepareCollection();

It will prepare the collection again with the default parameters and override yours.

Call the grand parent

return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();

instead of

return parent::_prepareCollection();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.