在Magento admin中添加网格中的产品类型过滤器

时间:2012-03-28 09:35:26

标签: magento grid admin product

在我的自定义模块中,我创建了一个加载所有产品的网格。我已经添加了以下列:

            $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(),
            ));

现在我想将产品类型列添加为下拉列表,以便我可以按产品类型过滤产品,即简单,可配置等。

EDITTED

刚刚将此功能添加到该功能中并且有效:

$this->addColumn('type', array(
                'header'=> Mage::helper('catalog')->__('Type'),
                'width' => '60px',
                'index' => 'type_id',
                'type'  => 'options',
                'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
            ));

1 个答案:

答案 0 :(得分:6)

刚刚将此功能添加到该功能中并且有效:

$this->addColumn('type', array(
                'header'=> Mage::helper('catalog')->__('Type'),
                'width' => '60px',
                'index' => 'type_id',
                'type'  => 'options',
                'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
            ));