I am implementing a plugin for a client that will use the 'Max Sale Quantity' value of a Magento Stock Item on a product as a means of setting an upper-bound on total customer purchases.
Because I need to check this condition in multiple events, controller actions, I cannot contain it to merely an Observer where I could create a local protected function that checks this condition from my Resource Model.
In my requirements I will be limiting the cart additions. But I find myself in a dilemma: from the controller
addAction I need to rely on
throw - however from
sales_quote_merge_before it seems that I could effectively unset the offending products and post a message to the
customer/session, though, I could throw and catch, respectively as with the controller action instead.
My questions are:
- Is this bad practice to effectively rely on
throwfrom the module helper?
- Is this, rather, a model method that I need to invoke?
- What is the best design strategy that allows me to keep my module DRY?
As of EE 1.12 I see only 4 instances of
Helper/Data.php files that throw - 3 of them are Api2/Oauth. Mage/Core does it once as well, but this seems to be the only other instance. Various 3rd parties look like they take different approaches here.
Any feedback is welcome.