Magento – How to combine two attributes in Adminhtml Grid view

adminhtmlmagento-1.9product-attributeproduct-grid

I am looking to learn how to combine both name and size attributes in the app/code/local/Mage/Adminhtml/Block/Catalog/Product/Grid.php file (yes, we will make a local) so that when I view products these two will appear together separated by a space. We have separated size as an attribute and we need it to appear in the name column of the grid. What we would see now might be something like "Fruit Drink Grape" and I wish to see "Fruit Drink Grape 8 fl. oz."

Best Answer

First: It's better to make a proper rewrite of this class or add your colums via observer.

However, you could update your name column like this:

$this->addColumn('name',
        array(
            'header'=> Mage::helper('catalog')->__('Name'),
            'index' => array('name', 'size'),
            'type' => 'concat',
            'filter_index' => "CONCAT(name, ' ', size)"
    ));