Snippets with the tag: availability

Check stock availability of a product

Description

code to check stock availability of product

Code

protected function _isAvailable(Mage_Sales_Model_Order_Item $orderItem, $qty)
{
	if ($orderItem->getProductId()) {
		$stockItem = Mage::getModel('catalog/product')
				  ->load($orderItem->getProductId())
				  ->getStockItem();

		if ($stockItem->getIsInStock() && (int)$stockItem->getQty() >= $qty) {
			return true;
		}
	}
	return false;
}