Why is magento missing a type class for bundle products?
-
16-10-2019 - |
Question
I am looking at a section of code that uses this:
if ($_item->getProduct()->getTypeId() === Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE)
to determine whether a product is configurable. I am now wanting to alter that to detect whether the product is a bundle - but it turns out, there is no Mage_Catalog_Model_Product_Type_Bundle
. Nor is there a Mage_Checkout_Block_Cart_Item_Renderer_Bundle
. In fact, I can't see to find any dedicated bundle classes, anywhere - it's like they don't exist!
What is the reason for this? How are developers supposed to deal with bundled products, without methods like getChildrenIds or TYPE_CODE? Are just supposed to be hardcoding things?
Solution
The bundled products were introduced after the release of Magento 1, and for reasons unknown, their implementation was separated out into a new module. Magento's modular system and shared config.xml
space allows for this sort of separation.
A quick glance at Mage_Bundle
reveals a type class
app/code/core/Model/Product/Type.php
and a renderer
app/code/core/Block/Checkout/Cart/Item/Renderer.php
OTHER TIPS
The bundle products were added later in Magento (after 1.0).
It's a totally separate module. Check Mage_Bundle
.