Magento – Get Product Stock Quantity

To get the quantity in stock for a particular product in Magento use the following code –

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

2 comments

  1. How to change it, just to show only if quantity is bigger than 0=zero
    Or to show some graphics icon when quantity is >0
    thanks

  2. loadByProduct($_product)->getQty();
    if($qtyStock>0)
    — here your code if there is available quantity–
    else
    echo “”;

    ?>

Leave a comment

Your email address will not be published. Required fields are marked *