Magento coupon entities in database

koramaiku picture koramaiku · Sep 29, 2012 · Viewed 10.1k times · Source

I'm trying to develop a Magento plugin which involves using coupons. Apparently after looking around I found I found a source that mentions use of a 'salesrule' table for coupons. However when I looked at my database i couldn't find it. However I did find 3 tables that had mention 'coupon' called 'coupon_aggregated', 'coupon_aggregated_order', and 'coupon_aggregated_updated'.

I just wanted to know what is the difference between the 3 tables so I can start using them? I am on the latest version of Magento.

Thanks guys in advance.

Answer

Alan Storm picture Alan Storm · Sep 29, 2012

The table you're looking for is indeed named

salesrule

There's also a table named salesrule_coupon, which contains specific coupon codes linked back to the main salesrule definition.

If your database is missing this table, something bad has happened to your system. Go to

Promotions -> Shopping Cart Price Rules

and create a new coupon code with a distinct title. Then dump your database content and search for the text of your distinct title. That will let you know which table your system is storing salesrules in.

The tables you mentioned above are aggregate data tables used for reporting only.