2012-03-28 149 views
4

在我的自定義模塊中,我創建了一個加載所有產品的網格。我有以下欄目已經增加:在Magento網格中添加產品類型過濾器admin

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

回答

6

剛剛將該的功能和它的工作原理:

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