Magento coupon entities in database

Magento coupon entities in database

July 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento coupon entities in database

Understanding Magento Coupon Entities

In Magento development, coupon entities play a crucial role in managing promotional offers for your e-commerce store. If you’re working on a plugin that involves coupons, it’s essential to understand the database schema and the purpose of each table.

The ‘salesrule’ Table: Core Magento Coupon Storage

The primary table used by Magento for storing coupon information is indeed named salesrule. This table contains details about all the created coupons in your Magento store, including:

  • Rule ID
  • Name
  • Description
  • Coupon code
  • Discount amount or percentage
  • Applicable product categories or products
  • Start and end dates
  • Usage limits

Here’s a simplified structure of the salesrule table:

CREATE TABLE salesrule (
  rule_id INT UNSIGNED NOT NULL PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  description TEXT,
  coupon_code VARCHAR(255),
  discount_amount DECIMAL(12,4),
  discount_step DECIMAL(12,4),
  -- Other fields like applicable product categories, usage limits, etc.
);

As you mentioned, there are additional tables that contain the word “coupon” in their names. However, these tables serve a different purpose compared to salesrule.

1. coupon_aggregated Table

This table stores information about coupons that have been applied at checkout. It’s primarily used for aggregating data related to coupon usage across multiple orders.

Key fields include:

  • entity_id: The primary key for the aggregated coupon.
  • rules_id: The rule ID from the salesrule table.
  • applied_rule_ids: A comma-separated list of rules applied to this order.

2. coupon_aggregated_order Table

This table links the coupon_aggregated entities with the specific orders they were applied to. It’s a junction table that helps track which coupons are associated with each order.

Key fields include:

  • entity_id: The primary key for the aggregated coupon.
  • order_id: The ID of the order where the coupon was applied.

3. coupon_aggregated_updated Table

This table is used to store updates about the status or usage counts of aggregated coupons. It’s primarily used by Magento’s cron jobs for updating coupon information in bulk.

Best Practices and Further Reading

When working with coupon entities, it’s recommended to use Magento’s built-in APIs and models rather than querying these tables directly. This ensure your plugin will be compatible with future updates and follows the Magento coding standards.

To learn more about Magento’s coupon API, you can refer to the official documentation: https://adobe-commerce.redoc.ly/2.4.0-admin/tag/coupons Laravel Company also provides detailed tutorials on extending Magento functionality through plugins and customizations.

Conclusion

In summary, while you may not find the salesrule table in your database due to Magento’s use of prefixes like ‘eav_’ for some core tables, understanding its purpose is crucial. The other three tables—coupon_aggregated, coupon_aggregated_order, and coupon_aggregated_updated—serve specific roles in tracking coupon usage across multiple orders.

When developing your plugin, focus on using Magento’s API for coupon management to ensure compatibility and maintainability. Always refer to the official documentation and consider learning from experienced developers at Laravel Company for the most effective approach.

Checkout Catalog Database Extensions

Our network