|
I am trying to add custom columns to the product grid within the Adminhtml module. I want to add columns that display custom product attributes and obviously filter the product grid by those attribute values. I have been successful in adding a column/filter when the attribute is a “Text Field”. I have another attribute that is a “Dropdown”. This is where I’m having trouble.
I have an attribute called “tv_make” that is of type “Dropdown” and has a few attribute values defined: “Sony”, “Toshiba”, etc. I have been able to add the custom column to the grid, but the values displayed are all ID values like: 13, 12, etc.
The core column “Attribute Set” which has code something like this:
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection') ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) ->load() ->toOptionHash();
$this->addColumn('set_name', array( 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, ));
Does anyone know how I would replace the code above so that I can get an “OptionHash” of a custom attribute’s defined values? This does not work and I’m not sure what to try next:
$makes = Mage::getResourceModel('eav/entity_attribute_collection') ->addAttributeToSelect('tv_model') ->load() ->toOptionHash();
$this->addColumn('make', array( 'header'=> Mage::helper('catalog')->__('TV Make'), 'width' => '80px', 'index' => 'tv_make', 'type' => 'options', 'options' => $makes, ));
|