Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在管理端显示所有(产品)类别列表:Magento_Magento_Module_Admin_Categories - Fatal编程技术网

如何在管理端显示所有(产品)类别列表:Magento

如何在管理端显示所有(产品)类别列表:Magento,magento,module,admin,categories,Magento,Module,Admin,Categories,我想在System.xml中显示模块管理端的所有产品类别,并将其显示为multiselect $_category = Mage::getModel('catalog/category')->load(); $collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id); $helper = Mage::helper('catalog/category'); fore

我想在System.xml中显示模块管理端的所有产品类别,并将其显示为multiselect

$_category = Mage::getModel('catalog/category')->load();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');

foreach($collection as $cat){
    if($_category->getIsActive()){
         $cur_category = Mage::getModel('catalog/category')->load($cat->getId());                       
         $helper->getCategoryUrl($cat);
         echo $cat->getName();
    } 
} 

但它不会显示我想要什么,我只想要产品类别。。。。有人能想到这件事吗。。。Thanx.

为了在系统配置中显示类别选择,我通过扩展Mage模型类和方法找到了解决方案

Mage\u Adminhtml\u Model\u System\u Config\u Source\u Category

然后拆下管路

->addPathFilter('^1/[0-9]+$')
现在它在系统配置中显示multiselect选项。您可以从列表中选择多个类别。

?php$\u helper=Mage::helper('catalog/category')?>
?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>

<?php if (count($_categories) > 0): ?>
    <ul>
        <?php foreach($_categories as $_category): ?>
            <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo "<b>".$_category->getName(). $_category->getId()."</b>" ?>
                </a>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                    <ul>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo "--".$_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

我正在使用Magento 1.7,但没有看到包含 ->addPathFilter(“^1/[0-9]+$”)

但是,删除下面的一行对我来说很有效。
->addRootLevelFilter()

看起来他们在1.7中将正则表达式更改为实际函数。这个函数做同样的事情,所以只需像Nahid做的那样,注释掉那行代码。