Automatic Related Products
Description
This module adds rule-driven automatic related products for Magento 2. It stores rule results in its own index table and renders them in multiple frontend positions (product, category, cart), with options to merge into or replace native related/upsell blocks.
Audience
For Magento merchants and teams who want centrally managed, rules-based related product merchandising across multiple storefront positions.
Features
- Rule management in Admin UI with conditions (products to display) and actions (where/when to display).
- Frontend placement options for product page, category page, cart page, and a custom position list.
- Merge modes: add to native related/upsell collections or replace them.
- Scheduled rule application via cron and manual application via Admin button and CLI command.
- Declarative schema with dedicated tables for rules, rule-store links, and computed related product IDs.
- Cache tag invalidation for affected products after rule reindex.
- Optional Hyva template switch (Hyva/default theme) and template selection per rule.
Installation
* = in production please use the --keep-generated option
Type: Composer
-
Add the composer repository to the configuration:
composer config repositories.automatic.related.products vcs https://github.com/kowalco/automatic-related-products
-
Add an access token for the private GitLab repository:
composer config --global --auth github-oauth.github.com <YOUR_TOKEN>
-
Install the module using Composer:
composer require kowal/module-automatic-related-products
-
Enable the module:
php bin/magento module:enable Kowal_AutomaticRelatedProducts
-
Apply database updates:
php bin/magento setup:upgrade
-
Flush the cache:
php bin/magento cache:flush
Configuration
- Admin path: Stores > Configuration > Kowal > Automatic Related Products.
- Config path:
automaticrelatedproducts/general/enabled.
- Scope: config is read on store scope, but the Admin field is only editable at Default scope (Show in Default = 1, Website = 0, Store View = 0).
- Admin rules: Automatic Related Products > Rules (admin route
automaticrelatedproducts/rule/*).
- ACL:
Kowal_AutomaticRelatedProducts::config for configuration and Kowal_AutomaticRelatedProducts::rule for rules.
Deployment And Operations
- Apply rules on demand in Admin via the “Apply Rules” button or via CLI
kowal:arp:apply (optional --ids with comma-separated rule IDs).
- Cron job
kowal_auto_related_product_cron_update_related_products runs every 8 hours at minute 20 in the default cron group.
- The module updates the
kowal_automaticrelatedproducts_index table and dispatches clean_cache_by_tags for affected product cache tags.
Deployment Checklist
- Verify
Kowal_AutomaticRelatedProducts is enabled and config flag is turned on.
- Create at least one rule with conditions and a target position.
- Apply rules once (Admin button or CLI) and confirm index table population.
- Confirm cron is running to keep index data up to date.
- Validate frontend placement on product/category/cart pages for the chosen positions.
CI/CD And Environments
- Ensure database schema is applied on deploy (declarative schema).
- Deploy static content for admin UI JS and frontend templates when needed.
- If you use Hyva, verify the Hyva template switch behavior.
Rollback
- Disable the module and remove it from Composer, then run Magento setup to remove schema changes if your deployment process supports module removal.
- Clear caches after disabling to avoid stale related products blocks.
Requirements / Notes
- Composer dependency:
kowal/base.
- Magento modules used in code: Catalog, CatalogRule, SalesRule, Ui, Backend, Store, Cron, CatalogInventory, Checkout.
- TargetRule is referenced in DI (
Magento\TargetRule\Block\Catalog\Product\ProductList\Related), which is available in Adobe Commerce; ensure compatibility if on Open Source.
- Optional integration:
Kowal_DynamicProductAttributes (adds custom validation filters) and Kowal_AutomaticRelatedProductsExtra (extra templates).
- Database tables:
kowal_automaticrelatedproducts_rule, kowal_automaticrelatedproducts_rule_store, kowal_automaticrelatedproducts_index.
Compatibility
- Module version in
composer.json: 1.0.18, setup_version in etc/module.xml: 1.0.16.
- No Magento version matrix is specified in the repository.
FAQ
- Which Magento versions are supported? Not specified in the codebase or README.
- Are fields like start/end date, customer groups, and display mode toggles enforced? No implementation found in backend logic beyond UI storage/serialization.
- Are there indexers or queues involved? None are defined in the module.
- The README Installation section contains unclosed fenced code blocks; the closing fence was added here to keep the document renderable.