Category Archives: Magento

List sub-categories on a category page flat catalog enabled Magento

<?php
$_cat = new Mage_Catalog_Block_Navigation();
$currentCat = $_cat->getCurrentCategory();
$subCats = Mage::getModel(‘catalog/category’)->load($currentCat->getId())->getChildren();
$subCatIds = explode(‘,’,$subCats);
?>

<?php if (count($subCatIds) > 1): ?>
<ul>
<?php foreach($subCatIds as $subCatId): ?>
<?php $subCat = Mage::getModel(‘catalog/category’)->load($subCatId); ?>

<li>
<a href=”<?php echo $subCat->getUrl(); ?>”>
<?php echo $subCat->getName(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

List sub-categories on a category page Magento

<?php
$_cat = new Mage_Catalog_Block_Navigation();
$currentCat = $_cat->getCurrentCategory();
$subCats = Mage::getModel(‘catalog/category’)->load($currentCat->getId())->getChildren();
$subCatIds = explode(‘,’,$subCats);
?>

<?php if (count($subCatIds) > 1): ?>
<ul>
<?php foreach($subCatIds as $subCatId): ?>
<?php $subCat = Mage::getModel(‘catalog/category’)->load($subCatId); ?>

<li>
<a href=”<?php echo $subCat->getUrl(); ?>”>
<?php echo $subCat->getName(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>