How to Get Product Quantity in PHTML for Magento 1.9

magento-1.9PHP

This is current code for short description in default list.phtml

  <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>

Now instead of this short_description I want to print quantity in list page.

Best Answer

You have to load proudct by cataloginventory model object and get current product quantity by using below code,

$_product is your list page product object.

 $stockQty = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);

 echo $stockQty->getQty();

You can debug more info of Quantity/Stock related data using,

echo "<pre>";print_r($stockQty->getData());
Related Topic