How to Find Sub categories by Parent Category id in Magento?

There are many ways to find Sub categories by parent category id in Magento and here we have given one of the code below.

$category_id = 5; // you can change category id according to you

$parentCat = Mage::getModel('catalog/category')->load($category_id);

$subCat = explode(',',$parentCat ->getChildren());

$collection = $parentCat
->addFieldToFilter("entity_id", array("in", $subCat) );

foreach($collection as $catname)
echo $catname->getName();



You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *