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

  1. Anju Aravind
    December 14, 2012

    yeppiieee……. It’s working….Thank you very much 😀

  2. silson
    December 14, 2012

    great dude…itz working….thank u my friend..

  3. Abubakar
    January 28, 2014

    Thanks for providing such helping material.

  4. Bijoy
    November 27, 2014

    Thanks Its’s work perfect…

Leave a Reply

Your email address will not be published.