Pages

Tuesday 18 June 2013

Show all categories in magento


<?php //Display all category in all page  ?>

<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>">
<?php echo $this->htmlEscape($_category->getName()) ?>
</a>
<?php
$_catid = $_category->getId();
$category = Mage::getModel('catalog/category')->load($_catid);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{?>
<ul>
<?php
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load($sub);
?>
<li class="lvel<?php echo $sub1->getLevel(); ?>">
<a href="<?php echo $sub1->getUrl();?>"><span><?php echo $sub1->getName(); ?></span></a>
</li>
<?php } ?>
</ul>
<?php }?>
</li>
<?php endforeach ?>

No comments:

Post a Comment