Reputation: 185
Is there a valuable way of getting the data of an configured Bundle product before adding it to the quote. Here the scenario:
What data is in the $item. Is this the hole user based and configured Product data
$item = $observer->getEvent()->getQuoteItem();
Is this the associated Product with the item, and if yes what is the difference
$product = $item->getProduct();
So far I understand is this the user selection
$infoBuyRequest = $item->getBuyRequest()->toArray();
$bundleOption = $infoBuyRequest['bundle_option'];
Here are a few things I don't understand:
How can i get the Options and Selections of the configured Bundle? If I var_dumb the item or product variables I get a lot of data. Not the total Options&Colections, just the ones the user has chosen.
The next question is: is the $item the actual object which will be stored in the database (sales_flat_quote_item), so the configured one?
What do I get through $item->getProduct(). Is this the associated product data?
How can I get the custom options (stored in different arrays:bundle_selection_attributes, bundle_option_ids, etc..)?
Upvotes: 0
Views: 1746
Reputation: 8050
If bundleproduct is added to the card, following is passed through the observer of the sales_quote_add_item
event:
So if you e.g. have a bundle product, with 4 options to choose a product and quantity, the observer is called 5 times.
In the database, a quote item is stored with the added bundle product and its selected underlying products.
$item->getProduct()
does return the object of the current quote item.
You can use functions like $product->getName()
and $product->getId()
, $product->getAttributeText('attribute_code')
, etc and all the logical stuff on it in the observer.
Upvotes: 1