Magento – Event to add product attribute to quote item, just once and not on sales_quote_item_set_product

cartmagento-1.8

I am looking for a way to transfer a product attribute to quote item whenever a product is added. I came across a method in which I could write an observer to hook onto th event:sales_quote_item_set_product and set the quote item attribute based on the product attribute.

But, I don't like this approach since sales_quote_item_set_product is dispatched every time a quote item is loaded from the DB. I'd like a one time thing wherein I fetch a product attribute at the time of add to cart and add it's value in a column in quote item. Is there an event I could hook onto?

I think checkout_cart_product_add_after should be a good prospect to explore…any thoughts?

Best Answer

You can try to use sales_quote_product_add_after.
That one is dispatched after you add a product to the cart.
the downside is that you get as parameter a list of all the items in the cart and you have to look for your latest item and set the attribute you need.
But you can easily identify it. It has the highest id.

Related Topic