2012-10-09 125 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; 

} 
相关问题