【问题标题】:magento subcategories in sidebar侧边栏中的 magento 子类别
【发布时间】:2011-11-28 07:49:29
【问题描述】:

我正在使用带有水平菜单的 Magento。此菜单显示所有父类别。我想要的是显示点击的父类别的子类别。

我怎么能意识到这一点?

提前致谢!

【问题讨论】:

    标签: magento categories


    【解决方案1】:

    您可以使用以下代码来获取父类别页面中的子类别:

    <?php
    $parentCategory     = Mage::registry('current_category');
    if($parentCategory){
        $catId              = $parentCategory->getId();
        $category           = Mage::getModel('catalog/category')->load($catId);
        $childCategories    = $category->getChildrenCategories();
        foreach($childCategories as $_category){
            print_r($_category->getData());
        }
    }
    

    希望这会有所帮助。

    谢谢

    【讨论】:

    • 我记得你应该测试,如果一个类别是活动的,因为你在这里也得到了不活动的。但现在不确定。
    • 是的 Flyinmana 是正确的。如果您不想显示非活动类别,则应进行过滤。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多