I am trying to display number of products in in each category.. and using this code to display all subcategory of category id:3 It is showing but it is counting not visible and disable product also,

    $cats = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();
    <?php foreach($cats as $category): ?>
         <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?>(<?php echo $category->getProductCount(); ?>)</a>
    <?php endforeach; ?>

Is there any good solution so that i can get exact count thats are visible-catalog search and active.


1 Answer 1


Follow that one:

$collection->setVisibility(array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG));     
echo $collection->count();
  • yes, using collection is the right way to fix your problem.
    – dagfr
    Commented Jul 31, 2013 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.