Magento get simple product's custom attribute value of a configurable product
If you want to get simple product's custom attribute value of a configurable product, like Color is your custom dropdown attribute of simple product and if you want to display available color of a configurable product on your category OR product list page or product details page, you can try following solution.
<?php $simpleCollection = ""; if($_product->getTypeId() == "configurable"){ $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product); $simpleCollection = $conf->getUsedProductCollection()->addAttributeToSelect('*'); foreach($simpleCollection as $simpleProduct){ $optLbl = $simpleProduct->getAttributeText('color'); echo $simpleProduct->getId()." ".$simpleProduct->getSku()." ".$optLbl."<br>"; } } ?>
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
Great. Works fine.
ReplyDeleteThanks...