Question

I would like to find all salesrules for a given product without the need to add it to the cart. I've been trying to find a solution for this all day but I can't come up with anything usefull/working.

Doing this for the catalogrules is pretty simple by using Mage_CatalogRule_Model_Resource_Rule::getRulesFromProduct.

But there is no such method anywhere for the salesrules.

Was it helpful?

Solution

The reason why there is no such method for SalesRules is that Sales Ruels (corresponds to "Shopping Cart price rules" in admin area) depend not only on products selection and they don't offer only discounts on certain products, but also to shipping, subtotal etc. And Sales Rule validity can depend on the factors which can't be determined until the product is added to specific shopping cart during buyer experience. For example, Sales Rule can validate only if subtotal > XXX.

So basically there is no 100% accuracy how one would espect this function to work. I.e. some people would expect that it returns all sales rules where the presence of this product is the only condition for the Sales Rule to validate, other would expect that this method must return all salesrules that offer discounts for this sku.

If you are looking for some specific behavior - tell the community more details so someone can answer by pasting the required code snippet.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top