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

后端 未结 6 1288
余生分开走
余生分开走 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条回答
  •  长发绾君心
    2020-12-29 05:01

    load($parentCategoryId);
    $subcats = $cat->getChildren();
    
    // Get 1 Level sub category of Parent category
    foreach(explode(',',$subcats) as $subCatid)
                  {
                    $_category = Mage::getModel('catalog/category')->load($subCatid);
      if($_category->getIsActive()) {
        echo '';
      }
    }
    
    ?>
    

    If you want 2 level , 3 Level, 4 Level or n Level subcategories of parent category than Click Here

提交回复
热议问题