How to get sub-categories of a specific parent category?

后端 未结 6 1293
余生分开走
余生分开走 2020-12-29 04:30

I had a main category (parent category) whose id = 10. I want to echo just its sub-categories. How can I do that?

6条回答
  •  萌比男神i
    2020-12-29 04:46

    This code may help if you want to get child category of every current category

        getCurrentCategory();
        $currentCategoryId= $_category->getId();
        $children = Mage::getModel('catalog/category')->getCategories($currentCategoryId);
        foreach ($children as $category)
        {
              echo $category->getName(); // will return category name 
              echo $category->getRequestPath(); // will return category URL
        }
        ?>
    

提交回复
热议问题