Showing posts with label Display sub categories in PHTML page. Show all posts
Showing posts with label Display sub categories in PHTML page. Show all posts

Thursday, 21 March 2013

Display all sub categories via phtml file



<div>
<?php
    $children = Mage::getModel('catalog/category')->getCategories(37);
    foreach ($children as $category):
        $category = Mage::getModel('catalog/category')->load($category->getId());
        echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
            $child = Mage::getModel('catalog/category')->getCategories($category->getId());
            foreach ($child as $cat):
                $cat = Mage::getModel('catalog/category')->load($cat->getId());
                echo '<li><a href="' . $cat->getUrl() . '">' . $cat->getName() . '</a></li>';
            endforeach;
    endforeach;
?>
</div>