Get the stock status of Magento Configurable Product

Posted on Updated on

Here is a way you can get the stock status of Magento Configurable Products collection.

$products = Mage::getResourceModel(‘catalog/product_collection’);
$products->addAttributeToFilter(‘type_id’, array(‘eq’ => ‘configurable’));
$products->addAttributeToFilter(‘status’, 1);
$products->addAttributeToFilter(‘visibility’, 4);

foreach ($products as $product) {
$stockStatus = Mage::getModel(‘cataloginventory/stock_item’) ->loadByProduct($product)->getIsInStock();
print ($stockStatus);
}

Advertisements