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

后端 未结 6 1546
轮回少年
轮回少年 2021-01-31 09:55

How can I get all the simple products associated with a configurable product? I found how to do the opposite (get a product configurable from a simple product) but that\'s not w

6条回答
  •  遥遥无期
    2021-01-31 10:09

    Use this below code

    Code to get the the full product information (where 3 is the configurable product Id)

    $product = Mage::getModel('catalog/product')->load(3); 
    $childProducts = Mage::getModel('catalog/product_type_configurable')
                        ->getUsedProducts(null,$product);
    
    foreach($childProducts as $child) {
        print_r($child->getName());  // You can use any of the magic get functions on this object to get the value
    }
    

    Another code to get the Children Product Ids

    $childProducts = Mage::getModel('catalog/product_type_configurable')
                        ->getChildrenIds(3);
    

    Hope this helps!!

提交回复
热议问题