0
votes

I am new to Magento 1.7.0.2 and I'm trying to make some small modifications on the product VIEW page.

I want to show the count of ACTIVE products under the current category where the product is showing. In category page list/grid, the category shows 5 items. In fact, they are 6 products under this category, but one of them is DISABLED.

If I use $category->getProductCount() I am getting 6 instead of 5 like it shows on the category page.

How can I show the correct product count under the current category like it is the case in category page?

Many thanks!

1

1 Answers

0
votes

I'm pretty new in Magento too, but try to do like this :

$products = Mage::getModel('catalog/category')->load($yourCategory->getId())
->getProductCollection()
->addAttributeToFilter('status', 1); // Enabled products only

echo $products->count();

I hope it will work.