Product Count Per Category in Magento
<ul>
<?php $id = 42;?>
<?php $cat = Mage::getModel('catalog/category')->load($id);?>
<?php $subcats = $cat->getChildren();?>
<?php foreach(explode(',',$subcats) as $subCatid):?>
<?php $_category = Mage::getModel('catalog/category')->load($subCatid);?>
<?php if($_category->getIsActive()):?>
<?php $productCount = Mage::getModel('catalog/category')->load($_category->getId())->getProductCount();?>
<li><a href="<?php echo $_category->getURL();?>"><span><?php echo $_category->getName();?><?php echo '('.$productCount.')'?></span></a></li>
<?php endif;?>
<?php endforeach;?>
</ul>
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment