Display product count of a category in main navigation

To display Product Count of a particular category in the main navigation, just include the following code in function _addCategoriesToMenu() of the observer file. The Observer file is located at appcodecoreMageCatalogModelObserver.php


$prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
			$prodCount = $prodCollection->count();
			if($prodCount=='0')
			{
				$prodCounts = '';
			}
			else
			{
				$prodCounts = ' ('.$prodCount.')';
			}
			$categoryData = array(
                'name' => $category->getName().$prodCounts,
                'id' => $nodeId,
                'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
                'is_active' => $this->_isActiveMenuCategory($category),
				'thumbnail' => Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()
            );

Continue reading