<div class="maincategory">
<?php
$rootcatId= Mage::app()->getStore()->getRootCategoryId();
$categories = Mage::getModel('catalog/category')->getCategories($rootcatId);
function  get_categories($categories) {
$array= '<ul class="cat-ul">';
foreach($categories as $category) {
$cat = Mage::getModel('catalog/category')->load($category->getId());
$array .= '<li class="'.$category->getUrlKey().'">'.
'<a href="' . Mage::getUrl($cat->getUrlPath()). '">' .$category->getName() . "</a>\n";
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$array .=  get_categories($children);
}
$array .= '</li>';
}
return  $array . '</ul>';
}
echo  get_categories($categories); ?>
</div>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

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