I have some simple catalog products in Magento, so I have their SKUs & IDs. Now I want to create a Bundled product using the array elements "bundle_options" & "bundle_selections" of the Bundle Items, which are used by the Magento Admin coding in its Observer Class.
Also in the Observer class, there are method calls of two functions "setBundleOptionsData()
" & "setBundleSelectionsData()
", for whose I am not able to find any function definition.
Please any professional post here, because I need some proper way of doing this thing. If it needs, overriding modules or using events, I will do, but I need really professional help. Thanks in advance.
Edit:-
Regarding the two methods mentioned above "setBundleOptionsData()
" & "setBundleSelectionsData()
", what I'm almost certain is that they are using some sort of PHP magic methods, but I don't know where the main logic of these magic methods are written?
Please anybody provide some correct answer. Any help is greatly appreciated.
Was having a hard time with this, but found that this got me over the hump:
Specifically, the
was the key
EDIT:: Also looks like there's a bit of a peculiarity when trying to add multiple options / selections. The setBundleOptionsData takes an array of options i.e.
And then the selections will be an array of selections arrays with their indexes corresponding to the options array:
or
$optionModel = Mage::getModel('bundle/option') ->addSelection('op111') ->setTitle('op111') ->setDefaultTitle('op111') ->setParentId($product_id) ->setStoreId($product->getStoreId()); $optionModel->save();
I am not using any Web Services, for this. I have simply used the following methods meant specifically for the Bundled Products, which are:-
For the first method, the details of the Bundle Options are provided to the method as the parameter in the form of an array. Similarly, for the second method "setBundleSelectionsData()", we are providing the details of the Bundle Selections to this method as the parameter in the form of an array.
This is the main logic in what goes through for adding any Bundled Product in Magento. Hope this helps to any newbies!!!
Please check this link for more details on Bundle Product creation in a proper way.