I am rewriting the magento admin panel grid for low stack products. In that I have added the new column color in the grid.But this column shows the attribute value instead of showing label. Below is my code which I added in grid.php

$this->addColumn('color', array(
    'header'    => Mage::helper('reports')->__('Product Color'),
    'sortable'  => false,
    'index'     => 'color',
    'type'      => 'options',

and below is the default collection in grid.php file.I didn't do anything in the collection.

$collection = Mage::getResourceModel('reports/product_lowstock_collection')
            ->setOrder('qty', Varien_Data_Collection::SORT_ORDER_ASC);

I am not sure if I have to do something in this collection.


  • 1
    you can get the label using a renderer file
    – Piyush
    Jan 21, 2015 at 10:43

3 Answers 3


Replace your code in Grid.php with this

$this->addColumn('color', array(
    'header' =>Mage::helper('reports')->__('Product Color'),
    'sortable' =>false,
    'index' =>'color',
    'type' => 'options',
    'renderer' => 'module_name/adminhtml_module_name_renderer_color'

Now create a file Color.php at path:


class Company_Modulename_Block_Adminhtml_Modulename_Renderer_Color extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
   public function render(Varien_Object $row)   
        $value = $row->getData($this->getColumn()->getIndex());
        $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color');
        $options = array();
        foreach( $attribute->getSource()->getAllOptions(true, true) as $option ) {
          $id = $option['value'];
           if ($id==$value) 
            echo $option['label'];


  • 1
    I wanted to add comment but due to new account, i haven't much reputation. Here is my solution to get value directly instead of getting from loop. Another thought you can add a break in loop once you got the value. $value = $row->getData($this->getColumn()->getIndex()); $attrValue = Mage::getResourceSingleton('catalog/product') ->getAttribute('color') ->getSource()->getOptionText($value); return $attrValue; I tried echo $option['label']; and i was getting double value. Thanks!
    – Vijay
    Feb 10, 2015 at 19:33

I found another way to solve this problem.

I have written the seperate function in helper file as,

public function color()
            $attribute_color = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color');
    $allOptions_color = $attribute_color->getSource()->getAllOptions(true, true);
    foreach ($allOptions_color as $color_instance) {
        $color[$color_instance['value']] = $color_instance['label'];
    return $color;

and I call this function in grid.php as

$this->addColumn('color', array(
        'header'    =>Mage::helper('reports')->__('Product Color'),
        'sortable'  =>false,
        'index'     =>'color',
        'type'  => 'options',
        'options'=> Mage::helper('reports')->color()

Just add new column like below in your Grid.php file.

$whereyoucome = Mage::getModel('eav/config')->getAttribute('customer_address', 'whereyoucome');
            $options = $whereyoucome->getSource()->getAllOptions(false);
            $whereyoucome = array();
            foreach ($options as $option){
                $whereyoucome[$option['value']] = $option['label'];

    $this->addColumn('whereyoucome', array(
            'header' => Mage::helper('sales')->__('Where you come'),
            'index' => 'whereyoucome',
            'filter_index' => 'billing.whereyoucome',
            'type' => 'options',
            'options' => $whereyoucome

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.