Showing posts with label Display all the subcategories of any category in Magento.. Show all posts
Showing posts with label Display all the subcategories of any category in Magento.. Show all posts

Thursday, 10 December 2015

How to get subcategories of current category in magento?

Display all the subcategories of any category in Magento.


If you have a category ID (current category OR any category) then you can easily display all the subcategories of that particular category.


Below code will load all the subcategories of the current category. 


If you want to get all the subcategories of any specific category, so assign category id in $categoryID. 



<?php 
         
       $catID = $current_category->getId(); //or any specific category id, e.g. 5

       $children = Mage::getModel('catalog/category')->getCategories($catID);

       foreach ($children as $category) 

         {
          
           echo $category->getId();
      
           echo $category->getName();
    
           echo $category->getRequestPath();
     
          print_r($category->getData());

}

?>