1
votes

In Magento I am trying to display all the SKU's for associated simple products on the product page of the configurable product. I have used the below code to display all colors but for some reason it doesn't work for all SKU's (I changed attribute text to SKU):

<?php
    $styles = array();
    if($_product->isConfigurable()){
    $allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
    foreach ($allProducts as $subproduct) {

            $styles[] = '<li>' . $subproduct->getAttributeText('color') . '</li>';

    }
    if(count($styles)>0) {
        sort($tyles);
        ?>

        <ul class="style-list">
        <? echo implode("", $styles); ?>
        </ul>

        <?
    }
}
?>        

Anyone know how to achieve this?

1
Have you tried $subproduct->getSku() - subroutines

1 Answers

2
votes
$sku = array();
if ($_product->isConfigurable()) {
    $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $_product); 
    foreach($childProducts as $child) {
        $sku[] = $child->getSku();
    }
}