0

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

0

Try to write like this. It will work.

$products=Mage::getModel('catalog/product')->getCollection();
foreach($products as $_product){

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

echo $stock->getQty();

}
1
  • 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.