Reputation: 531
In my custom module I created a grid which loads all the products. I have following columns added already:
$this->addColumn('entity_id', array(
'header' => Mage::helper('customer')->__('ID'),
'width' => '50px',
'index' => 'entity_id',
'type' => 'number',
));
$this->addColumn('name', array(
'header' => Mage::helper('customer')->__('Name'),
'index' => 'name'
));
$this->addColumn('price', array(
'header' => Mage::helper('catalog')->__('Price'),
'type' => 'currency',
'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
'index' => 'price'
));
$this->addColumn('sku', array(
'header' => Mage::helper('catalog')->__('SKU'),
'width' => '90',
'index' => 'sku',
));
$this->addColumn('status', array(
'header' => Mage::helper('catalog')->__('Status'),
'align' => 'left',
'width' => '80px',
'index' => 'status',
'type' => 'options',
'options' => array(
1 => 'Enabled',
2 => 'Disabled',
),
));
$this->addColumn('type', array(
'header'=> Mage::helper('catalog')->__('Type'),
'width' => '60px',
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
Now I want to add the product type column as a dropdown so that I can filter the products by produt type i.e. simple, configurable etc.
EDITTED
Just added this to the function and it worked:
$this->addColumn('type', array(
'header'=> Mage::helper('catalog')->__('Type'),
'width' => '60px',
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
Upvotes: 4
Views: 4383
Reputation: 531
Just added this to the function and it worked:
$this->addColumn('type', array(
'header'=> Mage::helper('catalog')->__('Type'),
'width' => '60px',
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
Upvotes: 6