I want to show how many active products are in a single category in Magento 1.8.
I need to display a few choosen categorys in a .phtml file and want to display how many products are in those categories.
To get all products count with visibility = Catalog search, Catalog and status = Enabled
<?php
$_category = Mage::getModel('catalog/category')->load(3); // 3 is the category id here
$_product = $_category->getProductCollection();
$_product->setVisibility(array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG));
$_product->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
echo $_product->count();
?>