Magento – How to validate quantity being added to cart from frontend

cartcheckoutquantityquote

I'm trying to validate and correct quantities of certain products being added from the frontend. I've found the checkout_cart_save_before event that fires during all frontend cart modifications. This is good, but I'm trying to see if there's a better and more efficient way of doing this, as, when listening to this event, I'll have to iterate through all of the products each time the cart is updated. This event also fires twice during a single cart update.

I've thought about rewriting specific controller actions, but that can be too intrusive as some actions don't have a convenient events to listen to modify quote item quantities.

There's also a Javascript method for each of the pages.. I understand the answers may be kind of an opinion, but I'd still like to obtain some feedback on this.

Best Answer

If you want to specify a max quantity, you can set it on the product admin in the inventory tab. The name of the field is Maximum qty allowed in the shopping cart.