I use bellow code to show number of articles from the category number 4 (in my case)! Magento is showing 65 articles from that category, but in the stock there are only 36 articles. What you would like to achieve is to show number of articles which are in stock. I don't want to include articles from out of stock.

$products_count = Mage::getModel('catalog/category')->load(4)

Try this way


$category = Mage::getModel('catalog/category')->load(4);
$productCollection = Mage::getResourceModel('catalog/product_collection')
                        ->addAttributeToSelect(array('name', 'image', 'price'))
                        ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));



echo $productCollection->getSize();

  • Working perfect :) – user15151 Oct 27 '15 at 17:11
  • great, you can up-vote answer as well :) – Akhilesh Patel Oct 27 '15 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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