<?php
        $allCats = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*');
         
        foreach($allCats as $category)
        {
            if($category->getParentId() ==  Mage::app()->getStore()->getRootCategoryId() && $category->getIsActive()) // it'll check the root category
            {
                $subcats = $category->getChildren();
                $total_cat_array=explode(',',$subcats);
                foreach($total_cat_array as $subId)
                {
                    $child = Mage::getModel('catalog/category')->load($subId);
                ?>
                    <li><a href="<?php echo $child->getUrl(); ?>"><?php echo $child->getName();?></a></li>
              <?php
                }
            }
        }      
  ?>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

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