I have the sku in the page and I want to see if product is in stock or out of stock and to do that I have done this:
$firstProductId = Mage::getSingleton('catalog/product')->getIdBySku('mysku');
$product = Mage::getModel('catalog/product');
$product->setId($firstProductId);
$inStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();
I want to know if I can achieve this without loading the whole product any other way which is more efficient or I am on the right path?
Best Answer
You can use this code which give stock in faster way using product id
Out is an array
An exmaple: