1
votes

I have a need to be able to find out if a sales coupon exists for a product.

The reason is that we would like to show on a product page, that a coupon exists for it and if needed show the coupon code also.

From my research over past couple of days, it seems salesRule are attached to be quote. Having said that in the validatior code I can see the discounted being calcualated per item. So there must be some-code that figures out if the coupon exist for an item.

If that does, we can run a cron job on a regular basis to update the attribute of a product with coupon codes that can be applied to it.

Can someone give some pointer where I can find the code which either 1. for each sales rule, lists out the product which meets the condition or 2. For each product, list out which sales rules meets the conditon.

Thanks

1
What conditions should be takes into account in your "system" when checking if rule can be applied ? As you probably know Coupon Codes can be applied based on many conditions for ex.: Cart Attribute - Subtotal, which in case of CRON based action would be pointless. - xyz
Lrrr: The SalesRules we have are mostly based on SKU and some product attribute. Our SKU are based on the supplier name and hence we may want to give a coupon for a particular supplier with price above X. - TheVyom
@seanbreeden: i went through the code but it will work if the list of SKU are contained in the salesRule. What is there were functions like Price greater than X. - TheVyom

1 Answers

0
votes

I think you should check Mage_SalesRule_Model_Validator::process method.