When are Magento rule-based product relations worked out?

When are Magento rule-based product relations worked out?

October 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
When are Magento rule-based product relations worked out?

Magento Rule-Based Product Relations: When Are They Worked Out?

As a senior developer specializing in e-commerce platforms, I often receive questions about the inner workings of Magento’s product relations. In this post, we’ll demystify when rule-based product relations like up-sells and cross-sells are processed.

Understanding Rule-Based Product Relations

In Magento, particularly versions 2.x (which you can explore in detail here), product relations are configured using rules. These rules determine the products that will appear as recommendations or additional purchases for a given item.

The relevant database tables for these relations include catalog_product_link and catalog_category_product. However, the key question remains: When do Magento’s product relation calculations actually occur?

Triggering Product Relation Calculations

1. Caching Mechanism

By default, Magento doesn’t cache rule-based product relations like a block that expires after a certain period. The calculation is typically executed on-the-fly whenever the product page is loaded. This ensures that the recommended products are always up-to-date based on the current rules and product catalog.

2. Product Save Event

Whenever you save a product in the Magento admin interface, the system doesn’t automatically recalculate all related product lists immediately. The relation calculation occurs when the product is viewed or loaded into a context where the relations are required (e.g., on a category page or checkout process).

However, if you have a large number of products and need to update their relations frequently, using Magento’s API or custom cron jobs can be more efficient.

3. Custom Cron Jobs

For scenarios requiring frequent updates, such as daily recalculations for all products, you can set up a custom cron job in the cron_expr field of the core_config_data table. This allows you to trigger relation calculations on your desired schedule.

To create an effective cron job:

  1. Set the path to the script: crontab -e
  2. Add your custom script in the following format: * * * * * /path/to/your/script.php > /dev/null 2>&1

Remember, running a cron job too frequently may impact performance if you have many products.

Best Practices for Managing Product Relations

To optimize product relation calculations:

  • Limit Rule-Based Products: Keep the number of rule-based products per item to a reasonable limit (e.g., 5-10) to minimize calculation time.
  • Use EAV Indexing: Ensure your EAV indexes are up-to-date and properly configured for optimal performance.
  • Optimize Your Database: Regularly clean up unnecessary data and optimize your database schema.

Conclusion

Magento’s rule-based product relations are not statically cached but calculated dynamically based on the current ruleset. The calculation is typically triggered when a product is loaded into context rather than on every save event or through periodic CRON jobs (though custom CRON can be used for heavy updates).

By understanding this behavior and applying best practices, you can effectively manage your site’s performance while providing relevant product recommendations to customers.

If you have any further questions about Magento development, feel free to explore our detailed tutorials at https://laravelcompany.com/magento-2/.

Catalog Cache Database Admin

Our network