2012-10-09 139 views
0

我正在使用Inchoo自定義設計的圖庫插件:http://inchoo.net/ecommerce/magento/magento-custom-designed-gallery/。這個插件創建一個畫廊,並可以給畫廊一個名字。Magento添加類別選擇選項卡自定義插件

雖然我想將插件鏈接到類別選擇器(以選項卡形式)。以便畫廊鏈接到一個類別。

我已經嘗試過被添加以下到應用程序/代碼/本地/ Inchoo/CPA /座/貓/編輯/ Tabs.php:

$this->addTab('categories', array(
       'label'  => Mage::helper('catalog')->__('Categories'), 
       'url'  => $this->getUrl('*/*/categories', array('_current' => true)), 
       'class'  => 'ajax', 
      )); 

它不會有任何影響。我能做什麼?我在Magento Extension Development中很新。

回答

1

我找到了解決方案。不幸的是不是以標籤的形式,但我找到了鏈接到類別的方法。

轉到應用程序/代碼/本地/ Inchoo/CPA /座/貓/編輯/標籤/ info.php的和激活addField功能後增加一個新功能:

$fieldset->addField('cat_select', 'select', array(
     'label'  => 'Category', 
     'class'  => 'required-entry', 
     'required' => true, 
     'name'  => 'cat_select', 
     'values' => $this->get_categories(), 
     'disabled' => false, 
     'readonly' => false, 
     'tabindex' => 1 
    )); 

添加以下功能選擇類別:

protected function get_categories(){ 

    $category = Mage::getModel('catalog/category'); 
    $tree = $category->getTreeModel(); 
    $tree->load(); 
    $ids = $tree->getCollection()->getAllIds(); 
    $arr = array(); 
    if ($ids){ 
    foreach ($ids as $id){ 
    $cat = Mage::getModel('catalog/category'); 
    $cat->load($id); 
    $arr[$id] = $cat->getName(); 
    } 
    } 

    return $arr; 

} 
相關問題