0

Magento default allow to create config product with simple products. Now can anyone help me to create config product with bundle products? Bundle product will be multiple simple products. Inventory will manage on simple products.Please help me

1
  • This is not possible. Commented Jul 24, 2018 at 19:05

1 Answer 1

1

I found the solution.

You needs to change two files:

  1. app/code/core/Mage/Catalog/etc/config.xml

    <configurable translate="label" module="catalog">
         <label>Configurable Product</label>
         <model>catalog/product_type_configurable</model>            
         <price_model>catalog/product_type_configurable_price</price_model>
         <composite>1</composite>
         <allow_product_types>
         <simple/>
         <virtual/>
         <bundle/>
         </allow_product_types>
         <index_priority>30</index_priority>                        
         <price_indexer>catalog/product_indexer_price_configurable</price_indexer>
     </configurable>
    
  2. app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php

You need to manage stock based on bundle product in function getJsonConfig. Magento check stock based on simple product but bundle product use stock simple products. Default theme does not check in stock and out stock logic but any custom theme can have option.

    $selectionCollection = $_product->getTypeInstance()->getSelectionsCollection($_product->getTypeInstance()->getOptionsIds());
    $qty = false;
    foreach ($selectionCollection as $option) 
    {
        $product_id = $option->product_id;
        $bundleOption = Mage::getModel('catalog/product')->load($product_id);

        $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($bundleOption);

        if ($qty === false) {
        $qty = $stock->getQty();
        } else {
        $qty = min(array($qty, $stock->getQty()));
        }
    }

    echo $qty;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.