Добавить фильтр типа продукта в сетке в Magento Admin - PullRequest
4 голосов
/ 28 марта 2012

В своем пользовательском модуле я создал сетку, которая загружает все продукты.У меня уже добавлены следующие столбцы:

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

Теперь я хочу добавить столбец типа продукта в качестве раскрывающегося списка, чтобы можно было фильтровать продукты по типу продукта, то есть просто, настраиваемо и т. Д.

РЕДАКТИРОВАННЫЙ

Просто добавил это в функцию, и она заработала:

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

1 Ответ

6 голосов
/ 01 мая 2012

Просто добавил это в функцию, и она заработала:

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