0

im using this code to get all product collections and Qty but is returning null

$products = Mage::getModel('catalog/product')
        ->getCollection()
        ->addAttributeToSelect('*');

        if(!empty($products)) {
            foreach($products as $product) {
                $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($products);
                $qty = $stock->getQty();
                var_dump($qty);
            }
        }

this code return "NULL"

3

1 Answer 1

1

You can try this ... add

$products
    ...
    ->setFlag('require_stock_items', true);

More info here Get product stock quantity in magento

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.