Catalog Price Rules
Describe catalog price rules: setup, indexing (catalogrule_product_price table), performance impact, debugging strategies, and comparison to special pricing.
Catalog Price Rules Overview
What Are Catalog Price Rules?
Catalog price rules allow you to apply discounts to sets of products (or all products) based on conditions, with optional customer group targeting.
Location: Marketing → Catalog Price Rule (admin panel)
Key Features
- Filter products by attributes, categories, SKU, etc.
- Target specific customer groups (e.g., Wholesale, Retail)
- Apply percentage or fixed amount discounts
- Set date ranges for active periods
- Priority and stop further rules processing
Catalog Price Rules vs Special Pricing
| Feature | Catalog Price Rules | Special Pricing |
|---|---|---|
| Scope | Global sales across product sets | One-off products or small groups |
| Setup | Rule-based, conditions-driven | Manual per-product |
| Customer Groups | Can target specific groups | Applies to all customers |
| Maintenance | Centralized rule management | Edit each product individually |
| Best For | Sales events, category discounts | Individual product promotions |
How Catalog Price Rules Are Indexed
Catalog price rules are indexed for performance. The indexed data is stored in the catalogrule_product_price table.
Key Points
- Not indexed by Price Indexer: Catalog rules have their own indexer.
- Catalog Product Rule Indexer: Dedicated indexer for catalog rules.
- Table Structure: Stores rule-based prices per product, customer group, website, and date.
The IndexBuilder class builds the catalog rule indexes.
Indexer Behavior
When a catalog price rule is saved or products change:
- Indexer evaluates which products match rule conditions.
- Calculates discounted prices for matching products per customer group.
- Stores results in
catalogrule_product_pricetable. - Frontend reads from this table to display catalog rule prices.
Performance Impact
Catalog price rules have a slight performance impact.
Why?
- Rules are pre-calculated and stored in
catalogrule_product_price. - Frontend queries this indexed table rather than evaluating rules on-the-fly.
- Indexing runs during reindex or on schedule (via cron).
Performance Considerations
- Indexing time: Large catalogs with many rules may take longer to index.
- Indexer mode: "Update on Save" impacts admin performance; "Update on Schedule" defers to cron.
- Frontend: Minimal impact—reads from indexed table.
Debugging Catalog Price Rules
Debugging is easier with access to a production database copy (without sensitive customer data).
Two Places to Check
- Is the problem the data going INTO the indexed table?
- Check rule conditions: Are products matching the rule?
- Verify customer groups are assigned correctly.
- Ensure rule is active and within date range.
- Run indexer manually:
bin/magento indexer:reindex catalogrule_rule
- Is the problem the data coming OUT of the indexed table?
- Query
catalogrule_product_pricetable for affected products. - Verify discounted prices exist for the customer group.
- Check if frontend code reads from the indexed table correctly.
- Look for price retrieval logic in price models.
- Query
Set breakpoints in IndexBuilder to trace rule evaluation and index generation.
Debugging Steps
- Verify Rule Configuration:
- Check rule is active (Status = Active).
- Verify date range includes current date.
- Ensure customer groups are selected.
- Review conditions and actions.
- Check Indexer Status:
bin/magento indexer:status catalogrule_rule bin/magento indexer:status catalogrule_product - Reindex Manually:
bin/magento indexer:reindex catalogrule_rule catalogrule_product - Query Indexed Table:
SELECT * FROM catalogrule_product_price WHERE product_id = [PRODUCT_ID] AND customer_group_id = [GROUP_ID]; - Check Product Matches Rule:
- Manually evaluate rule conditions against product attributes.
- Use admin Preview > Products Matched to see which products match.
- Review Logs:
- Check
var/log/system.logandexception.logfor errors during indexing.
- Check
Catalog Product Rule Indexers
Two indexers handle catalog price rules:
- catalogrule_rule: Indexes rule data itself.
- catalogrule_product: Indexes product-rule associations and calculates prices.
Both must be up-to-date for rules to apply correctly.
Common Issues and Solutions
| Issue | Possible Cause | Solution |
|---|---|---|
| Rule not applying | Indexer not updated | Reindex catalogrule_rule and catalogrule_product |
| Wrong price displayed | Multiple rules with priorities | Check rule priority and "Stop Further Rules Processing" |
| Rule applies to wrong products | Condition misconfiguration | Review rule conditions; use Preview feature |
| Rule not showing for customer | Customer group mismatch | Verify customer's group matches rule's target groups |
| Slow indexing | Large catalog or complex rules | Optimize rules; use "Update on Schedule" |
Further Reading
Exam Tips
- Setup: Marketing → Catalog Price Rule; filter products, select customer groups, apply discounts.
- vs Special Pricing: Rules = global/rule-based/customer groups; Special = manual/one-off/all customers.
- Indexing: Stored in
catalogrule_product_pricetable; NOT in price indexer; uses Catalog Product Rule indexer. - Performance: Slight impact; indexed data; use "Update on Schedule" for large catalogs.
- Debugging: Check data INTO index (rule conditions, reindex) and data OUT of index (query table, frontend logic).
- IndexBuilder:
\Magento\CatalogRule\Model\Indexer\IndexBuilderbuilds indexes. - Indexers:
catalogrule_ruleandcatalogrule_product.