【问题标题】:Magento add category select tab to custom pluginMagento 将类别选择选项卡添加到自定义插件
【发布时间】:2012-10-09 22:52:47
【问题描述】:

我正在使用 Incho 自定义设计的图库插件:http://inchoo.net/ecommerce/magento/magento-custom-designed-gallery/。这个插件创建了一个画廊,并且可以给画廊一个名字。

虽然我想将插件链接到类别选择器(以选项卡形式)。以便画廊链接到一个类别。

我已经尝试将以下内容添加到 app/code/local/Inchoo/Cpa/Block/Cat/Edit/Tabs.php:

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

它没有任何作用。我能做些什么?我是 Magento 扩展开发的新手。

【问题讨论】:

    标签: magento


    【解决方案1】:

    我找到了解决方案。不幸的是不是以标签的形式,但我找到了一种链接到类别的方法。

    进入 app/code/local/Inchoo/Cpa/Block/Cat/Edit/Tab/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;
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      • 2017-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多