Many times we need to show product count per category in magento. So here I am showing to how many products (Product count) in that categories. First of all I get all categories based on category position with ascending order and then get product count for that category.
It shows like below example:
Laptops (4)
Hard Drives (4)
Root Catalog (5)
Monitors (4)
Shirts (19)
Shoes (46)
Get category and product count in magento
<?php
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addAttributeToSelect('my_attribute')
->addAttributeToSelect('position')
->addAttributeToSort('position', 'ASC')
->setLoadProductCount(true)
->addAttributeToFilter('is_active',array('eq'=>true))
->load();
?>
<?php foreach($categories as $key=>$category): ?>
<?php if($category->getName() != ''):?>
<?php $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category); // Magento product collection ?>
<a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a> (<?php echo $prodCollection->count() ?>)<br/>
<?php endif;?>
<?php endforeach; ?>
Justwebdevelopment can also help you in...
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services


Magento developers many times get confused for designing a website in a unique way. After visiting this article, one can easily get the overview of designing a particular Ecommerce website. As the matter of fact, various platforms require different kinds of designs for better engagement of a product. So after visiting here, one can easily get the best overview of designing a website.