How to fetch all associative product of a configurable product in magento

Configurable product is the product which is created by some Associated product, If you have an configurable product and you want to get list of all associated product and it's attribute then just write the below

You must have your configurable product Id, My configurable product Id is 11 $id=11; //Use your Configurable product Id
$_product = new Mage_Catalog_Model_Product();
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($id);
foreach($childIds[0] as $key=>$val)
   $associatedProduct = Mage::getModel('catalog/product') ->load($val);
   echo $associatedProduct ->getName();
//Let you have a color attribute in each associated product then you can fetch by
   $colorids[] = $associatedProduct ->getColor();
   $colorname[] = $associatedProduct ->getAttributeText('color');

No comments:

Post a Comment