Get subcategories of a categories with images in magento
Posted by navaneeth on Dec 14, 2012 in Magento | 4 Comments

Here is the code to show all the subcategories inside an category in magento
<?php $children = Mage::getModel('catalog/category')->getCategories(10); foreach ($children as $category) { echo $category->getName(); } ?>
Here 10 is the id of the parent category
and to get the url for that category use
<?php $url=Mage::getModel('catalog/category')->load($category->getId())->getURL(); ?>
You can also get the image of an category by adding this inside the for loop
<?php $imageurl=Mage::getModel('catalog/category')->load($category->getId())->getImageUrl(); ?>
Inorder to get the child categories of a category when include in navigation set to no
we have to use the below code to get the children categories
$_categories = Mage::getModel('catalog/category')->load(10)->getChildrenCategories(); foreach ($_categories as $category) { echo $category->getName(); }
4 Comments on “Get subcategories of a categories with images in magento”
Anju Aravind
December 14, 2012yeppiieee……. It’s working….Thank you very much 😀
silson
December 14, 2012great dude…itz working….thank u my friend..
Abubakar
January 28, 2014Thanks for providing such helping material.
Bijoy
November 27, 2014Thanks Its’s work perfect…