在波尔图主题Magento的类别页面上显示子类别列表

时间:2017-05-18 08:47:53

标签: php magento-1.9

我试图在波尔图主题的类别页面上显示子类别列表,但在Magento中没有任何作用。我也试过这个tutorial

1 个答案:

答案 0 :(得分:0)

您必须转到app/design/frontend/theme/template/catalog/product/list.phtml

这是您的类别列表页面。

您可以在这里输入代码

 <?php

  $currCategoryId = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getId();
  $category = Mage::getModel('catalog/category')->load($currCategoryId);
                  $subcategories = $category->getChildrenCategories();
                if(count($subcategories)>0){ 
                         $count=1; 
                    foreach ($subcategories as $subcategory) {
                        $category1 = Mage::getModel('catalog/category')->load($subcategory->getId());
                        $subcategories1 = $category1->getChildrenCategories();
                        echo $subcategory->getName()."<br/>";
                        if(count($subcategories1)>0){ 

                            foreach ($subcategories1 as $thirdLevelCategory) {
                                echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
                                echo $thirdLevelCategory->getName()."<br/>";
                            }
                        }
                    }

                }   
   ?>

注意:最好创建一个块并从块中加载数据,或者您可以在模块中创建一个帮助程序并在模板中使用它。