This is the second part of our discussion on Magento Bundle product type. In the first part we concentrated on the back-end management of bundle products and on the front-end display specifics. In this post we will discuss the functionality implemented by the Bundle product type class; but first, let’s look at bundle options and selection classes.
Bundle Option and Selection Classes
Bundle options are represented by model class Mage_Bundle_Model_Option and a resource model Mage_Bundle_Model_Resource_Option. The option data is saved in two tables: catalog_product_bundle_option and catalog_product_bundle_option_value. The first table contains the general option data such as:
- option_id – a unique option identifier;
- parent_id – ID of the bundle product to which the option belongs to;
- required – a flag indicating that a bundle can’t be added to cart without this option being configured;
- position – parameter used to sort lists of bundle options in an ascending order;
- type – one of four allowed option types: drop-down, radio buttons, multiselect, and checkbox. The string constants corresponding to each type are defined in the Mage_Catalog_Model_Product_Option class:
class Mage_Catalog_Model_Product_Option extends Mage_Core_Model_Abstract { /**code omitted for brevity **/ const OPTION_TYPE_DROP_DOWN = 'drop_down'; const OPTION_TYPE_RADIO = 'radio'; const OPTION_TYPE_CHECKBOX = 'checkbox'; const OPTION_TYPE_MULTIPLE = 'multiple'; /**code omitted for brevity **/ }
Listing 5. Option type constants, /app/code/core/Mage/Catalog/Model/Product/Option.php, line 65