I'm trying to display a list of of the stock status for the simple products related to a configurable product. This is working fine except when for the first instance of the array when the related attribute 'Size' isn't display.
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php $instock = "Next Day"; ?>
<?php $outofstock = "4 to 7 Days"; ?>
<?php $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product); ?>
<?php $col = $conf->getUsedProductCollection()->addAttributeToSelect('Size')->addFilterByRequiredOptions(); ?>
<ul>
<?php foreach($col as $simple_product){
$qty = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple_product)->getQty());
$size = Mage::getModel('catalog/product')->load($simple_product->getId())->getAttributeText('Size');
?>
<li>
<?php
if ( $qty >= 1 )
{echo $qty, " ",$size," ",$instock;}
else
{echo $qty, " ",$size," ",$outofstock;} ?>
</li>
<?php } ?>
</ul>
The results set is looking like this:
99 Next Day
99 9 Next Day
99 8.5 Next Day
99 8 Next Day
99 7.5 Next Day
0 7 4 to 7 Days
99 12 Next Day
99 11.5 Next Day
99 11 Next Day
99 10.5 Next Day
99 10 Next Day
Any pointers on what I've got wrong and how to get the first attribute displayed?