How to use bundle products in configurable products?
- Digital Engineering
- Ecommerce
How to use bundle products in configurable products?
By default magento does not allow to use bundle products in configurable products. You can change few files to make it work.
You needs to change two files:
1. app/code/core/Mage/Catalog/etc/config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<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.
1 |
$selectionCollection = $_product->getTypeInstance()->getSelectionsCollection($_product->getTypeInstance()->getOptionsIds()); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$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; |
Related content
Auriga: Leveling Up for Enterprise Growth!
Auriga’s journey began in 2010 crafting products for India’s