Magento – Add Qty to Product before adding to cart

addtocartevent-observermagento-1.9

I am looking for an event observer which is suitable for my requirements.

My requirement is I add to cart the product but qty I want to add to this cart will be decided by the product attribute.

I will be having a custom attribute called attribute1 which will have an integer number.

So when I add to cart the product, I will get the attribute and number which is defined in it and I set this number as a qty to the product which is getting added to cart.

So following are the observers I tried, but not getting any success
checkout_cart_product_add_after and I am looking for event something like checkout_cart_product_add_before but it seems not their.

Please help me.

Best Answer

You could use the sales_quote_product_add_after event. You can access there the added quote items and change the quantity. Just be careful not to change the quantity for items that have a parent set (you can check if $item->getParentItem() is set).

Related Topic