I've added a custom attribute to the products grid in the admin area using the following code in /app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php under function _prepareColumns()
It works fine, but now when searching with any search filter - the new attribute column is showing no values.
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','custom_column');
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attributeData = $attribute->getData();
$frontEndLabel = $attributeData['frontend_label'];
$attributeOptions = $attribute->getSource()->getAllOptions();
$attributeOptions2 = array();
foreach ($attributeOptions as $value) {
if(!empty($value['value'])) {
$attributeOptions2[$value['value']] = $value['label'];
}
}
$this->addColumn('custom_column',
array(
'header'=> Mage::helper('catalog')->__('Custom Column'),
'width' => '150px',
'index' => 'custom_column',
'type' => 'options',
'options' => $attributeOptions2,
));
And under _prepareCollection() I've added the following code:
$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('custom_column');
I think it's simple but I'm not catching it at the moment, any help is highly appreciated!
EDIT:
When searching with filters - the column is populating with values EXCEPT if the filter was the Name column.