I got the following code to check the status of a configurable product. Basically, the stock status of all child products has to be checked, and as all child products are out of stock, the command would display 'OutOfStock', but the commands not still achieving what I want, since it displays InStock when all child products are out of stock. What could be going wrong?
<?php
$_product = Mage::registry('current_product');
$stockItem = $_product->getStockItem();
$isInStock = $stockItem->getIsInStock();
$stockString = ($isInStock ? "In" : "OutOf")
;?>
<script type="application/ld+json">
{
"offers": {
"availability": "<?php echo $stockString ."Stock"; ?>",
}
}
</script>
`
getUsedProductCollection()
and loop through it to get what ever information you're interested in. The basic concept behind this idea can be seen here (even though here it was about getting the data from the first item only which however you should be able to bypass by not applying->setPageSize(1)->getFirstItem()
): magento.stackexchange.com/questions/18055/…