I'm trying to show the name + quantity in stock for each simple product of a configurable product. I'm trying
<?php
if($_product->isConfigurable()) {
/* $itemsinstock = 0; */
echo '<p>Aantal in voorraad van:</p>';
echo '<table>';
foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();
$stock = round($stock,2);
echo "<tr><td>". $simple->getName()." <td> : </td><td style='font-weight : bold; text-align : right;'>$stock</td></tr>";
/* $itemsinstock+= $stock; */
}
echo '</table>';
/* echo $itemsinstock; */
} else {
echo "<p class='availability in-stock'>". $this->__('Availability:') ." <span>". number_format(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(), 0) ."</span></p>";
}
?>
I do see the quantity, but the name is empty. When I replace getName by getId, I get the correct id.
I read somewhere that the name is an attribute, but I can't get the name. I must do something wrong, but what/where?
Can some of you point me to the right direction?