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 Answer
I found the solution.
You needs to change two files:
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>
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;