How can I can I display the available inventory level on the category page? I have the code below in the category screenshot below, however the inventory displays 0 in the default.phtml file.

<?php echo 'Qty: '.$_product->getStockItem()->getQty() ?> 

enter image description here

Thank you

2 Answers 2


You can try

$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
echo $stock->getQty();
  • Thank you @Akhilesh How can I insert the round variable to round the number. Currently it is showing for example 12.00.
    – Elvis
    Dec 1, 2015 at 16:14
  • 1
    use <?php echo round($stock->getQty()); ?> Dec 1, 2015 at 16:22
  • Thank you@Akhilesh. That worked. This is the code '<?php echo $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct ($_product); echo round($stock->getQty()); ?> '
    – Elvis
    Dec 1, 2015 at 16:40
  • Thank you @Akihilesh, I did mark the question as answered. Please mark my question. Thank you.
    – Elvis
    Dec 1, 2015 at 16:43

I recommend using the following to output inventory count.

    $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id);
    echo round($stock->getQty());

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.