Latest 100 public snipts »
robertbanh's
snipts » categories
showing 1-1 of 1 snipts for categories
-
∞ Magento - get categories and sub cat for nav
<?php $obj = new Mage_Catalog_Block_Navigation(); $store_cats = $obj->getStoreCategories(); $current_cat = $obj->getCurrentCategory(); $current_cat = (is_object($current_cat) ? $current_cat->getName() : ''); echo "<ul>"; foreach ($store_cats as $cat) { //if ($cat->getName() == $current_cat) { echo '<li class="parent"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n"; foreach (Mage::getModel('catalog/category')->load($cat->getId())->getChildrenCategories() as $childCategory) { echo '<li><a href="'.$childCategory->getUrl().'">'.$childCategory->getName() .'</a></li>'; } echo "</ul>\n</li>\n"; //} else { // echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n"; //} } echo "</ul>"; ?> ?>


