1

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

TheVyom
  • 523
  • 2
  • 11
  • 16
  • 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 Mar 04 '12 at 08:20
  • This should help: http://stackoverflow.com/questions/9483072/display-collection-of-shopping-cart-rules-and-products-categories-associated-to/9484460#9484460 – seanbreeden Mar 04 '12 at 14:11
  • 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 Mar 05 '12 at 09:55
  • @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 Mar 05 '12 at 09:56

1 Answers1

0

I think you should check Mage_SalesRule_Model_Validator::process method.

xyz
  • 2,197
  • 2
  • 23
  • 41