6.03

Catalog Price Rules

Describe catalog price rules: setup, indexing (catalogrule_product_price table), performance impact, debugging strategies, and comparison to special pricing.

Why This Matters: Catalog price rules enable global sales and discounts across product sets with customer group targeting. Understanding indexing, the catalogrule_product_price table, and debugging strategies is essential for troubleshooting pricing issues.

Catalog Price Rules Overview

mindmap root((Catalog Price Rules)) Setup Marketing > Catalog Price Rule Filter products Select customer groups Apply discounts vs Special Pricing Global sales vs one-off Customer group targeting Rule-based vs manual Indexing Catalog Product Rule indexer catalogrule_product_price table Not in price indexer Performance Slight impact Indexed data Debugging Data into index? Data out of index applied? IndexBuilder

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
Use Case: Apply a 20% discount on all "Electronics" category products for "Wholesale" customer group from Black Friday to Cyber Monday.

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
When to Use Catalog Price Rules: When you need to apply discounts to many products, target customer groups, or automate sales events.

How Catalog Price Rules Are Indexed

Catalog price rules are indexed for performance. The indexed data is stored in the catalogrule_product_price table.

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.
\Magento\CatalogRule\Model\Indexer\IndexBuilder

The IndexBuilder class builds the catalog rule indexes.

Indexer Behavior

When a catalog price rule is saved or products change:

  1. Indexer evaluates which products match rule conditions.
  2. Calculates discounted prices for matching products per customer group.
  3. Stores results in catalogrule_product_price table.
  4. Frontend reads from this table to display catalog rule prices.
Note: If indexer is set to "Update on Schedule," changes may not appear immediately.

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.
Best Practice: Use "Update on Schedule" for large catalogs to avoid admin slowdowns.

Debugging Catalog Price Rules

Debugging is easier with access to a production database copy (without sensitive customer data).

Two Places to Check

  1. 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
  2. Is the problem the data coming OUT of the indexed table?
    • Query catalogrule_product_price table 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.
\Magento\CatalogRule\Model\Indexer\IndexBuilder

Set breakpoints in IndexBuilder to trace rule evaluation and index generation.

Debugging Steps

  1. Verify Rule Configuration:
    • Check rule is active (Status = Active).
    • Verify date range includes current date.
    • Ensure customer groups are selected.
    • Review conditions and actions.
  2. Check Indexer Status:
    bin/magento indexer:status catalogrule_rule
    bin/magento indexer:status catalogrule_product
  3. Reindex Manually:
    bin/magento indexer:reindex catalogrule_rule catalogrule_product
  4. Query Indexed Table:
    SELECT * FROM catalogrule_product_price 
    WHERE product_id = [PRODUCT_ID] 
    AND customer_group_id = [GROUP_ID];
  5. Check Product Matches Rule:
    • Manually evaluate rule conditions against product attributes.
    • Use admin Preview > Products Matched to see which products match.
  6. Review Logs:
    • Check var/log/system.log and exception.log for errors during indexing.

Catalog Product Rule Indexers

Two indexers handle catalog price rules:

  1. catalogrule_rule: Indexes rule data itself.
  2. 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_price table; 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\IndexBuilder builds indexes.
  • Indexers: catalogrule_rule and catalogrule_product.