On the product page, i have to display associated product inventory stock qty on a dropdown. Currently its display undefined.

enter image description here

1 Answer 1


Try to write like this. It will work.

foreach($products as $_product){

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

echo $stock->getQty();

  • Thanks, Rama but please tell me where I should put this code. Commented Jun 22, 2017 at 9:37

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.