How to include custom customer attribute in to magento admin customer grid?
-
12-12-2019 - |
Question
I added customer mobile no while customer register in the registration page.
The created mobile no is attribute stored in eav_attribute
table with entity_type_id
1.
I tried to add these field in the admin grid view on the customer page.
I edit the grid.php
file and adding these lines to grid.php
$this->addColumn('Telephone', array(
'header' => Mage::helper('customer')->__('Telephone'),
'width' => '100',
'index' => 'billing_telephone'
));
$this->addColumn('mobile', array(
'header' => Mage::helper('customer')->__('Mobile'),
'width' => '100',
'index' => 'mobile'
));
The label is shown in the view after Telephone, but the value for the mobile no is not retrieved in the grid. How can i retrieve the value of mobile number in the grid?
Solution
Look for _prepareCollection()
method in customer grid class Mage_Adminhtml_Block_Customer_Grid
and add ->addAttributeToSelect('mobile')
Also, you shouldn't edit core files directly.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange