1

我正在尝试为自定义管理模块中的类别和子类别构建类别树,如果可能的话,覆盖产品编辑选项卡中存在的默认类别树。

下面是我正在工作的代码,它能够构建类别树,但它缺乏复选框功能。任何建议将不胜感激

<?php 
$rootcatId= Mage::app()->getStore()->getRootCategoryId(); 
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
function  get_categories($categories) {
    $array= '<ul>';
    foreach($categories as $category) {
        $cat = Mage::getModel('catalog/category')->load($category->getId());
        $count = $cat->getProductCount();
        $array .= '<li>'.
        '<a href="' . Mage::getUrl($cat->getUrlPath()). '">' . 
                  $category->getName() . "(".$count.")</a>\n";
        if($category->hasChildren()) {
            $children = Mage::getModel('catalog/category')->getCategories($category->getId());
             $array .=  get_categories($children);
            }
         $array .= '</li>';
    }
    return  $array . '</ul>';
}
echo  get_categories($categories); ?>
4

1 回答 1

0
    Please clarify your question as it's bad idea to override core functionality because same function is used by different modules instead you can check functionality of these 

app/design/adminhtml/default/default/template/catalog/product/edit/categories.ph‌​tml app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php 

and then reflect these to your template files
于 2013-06-27T10:48:17.580 回答