Get All simple product from a Configurable Product in Magento Product View

In Magento, a configurable product is made up of multiple simple products, each with different options such as size or color. To get all the simple products associated with a configurable product in the product view, you can use the following code snippet:


$product = Mage::getModel('catalog/product')->load($configurableProductId);
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
foreach ($childProducts as $child) {
  // do something with each simple product

This code first loads the configurable product by its ID, then uses the getUsedProducts method to get an array of all the simple products associated with it. You can then loop through the array and access the details of each simple product, such as its ID, name, price, etc.

Watch a course Learn object oriented PHP

You can also use the following methods to get the details of simple product from configurable product


$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
foreach ($productAttributeOptions as $productAttribute) {
  foreach ($productAttribute['values'] as $attribute) {
    $simpleProduct = Mage::getModel('catalog/product')->load($attribute['product_id']);

This code snippet uses getTypeInstance method to get the attribute options of the configurable product and then iterating through the options to get the details of the simple product.