Friday, 5 February 2016

How to get sub-category by category id in Magento


How to get sub-category by category id in Magento

Try to use below code for subcategories in magento

$subcategoryCollection = Mage::getModel('catalog/category')
 ->getCollection()
 ->addAttributeToFilter('parent_id', 35);
foreach($subcategoryCollection as $_subcategoryCollection)
 {
  $categoryId = $_subcategoryCollection->getEntityId();
  $categoryName = Mage::getModel('catalog/category')->load($categoryId);
  $categoryName->getName();
 }

2 comments:

PHP Coder said...

How to get sub-category by category id in Magento

Muhammad Shumail said...

nice.