2

Here is my questions: What is the right event to hook in for adding a product to quote programmatically (entry sales_flat_quote_item table). Also i have to catch the items/products added to cart from an user/customer, because their data informations will determine the product which will be added programmatically. So the scenario would be:

  1. user/customer adds a product to cart
  2. find the right event for hook in
  3. fetch informations about the products added to cart
  4. add additional product to cart based on a product id and modified its data

In my opinion its better to work with the quote, before the products are written to the database.

I figure out how to add it through Mage_Sales_Model_Quote::_addCatalogProduct(). But i would like to do it through an event observer instead of overwriting core classes.

2

these are observer maches with your requirement.

sales_quote_add_item
sales_quote_product_add_after
checkout_cart_product_add_after
checkout_cart_add_product_complete
checkout_cart_update_item_complete
checkout_cart_update_items_before
checkout_cart_update_items_after
checkout_cart_save_before
checkout_cart_save_after
checkout_cart_product_update_after
sales_quote_product_add_after

Refer these links for events in magento

  1. http://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/
  2. http://www.magentocommerce.com/wiki/5_-_modules_and_development/reference/events

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.