Dynamic category rules in Magento 2 make the process of product management easier. Your products are added to the dynamic categories automatically if all the conditions are met. Thus, you eliminate manual work and automate store operations immensely.
Such an approach allows you to create automatic categories like Brands, Sale, Newly Added, Most Rated, etc. based on different product attributes.
In order to add a new dynamic category rule in Magento 2 Dynamic Categories Extension take the following steps:
1. Navigate to Catalog > Dynamic Category > Rules.
2. Press the Add New Rule button to create a new dynamic category rule.
3. Enable the Rule.
4. Set the Rule Name and add a Description if needed.
5. Indicate the Priority which defines how the rule should be processed. The higher the number the later the rule will be processed.
6. Select Categories Type - Static in case you have already created category in Magento and Pattern if you want to create categories automatically based on the product attribute pattern.
7. Set the Category, you create this rule for and which you want to add products to.
8. Assign the rule to the Web Sites.
9. Choose what method to Apply the rule By.
- On Product Save — rule will be applied every time you save a product that fits the rule conditions.
- Cron — rule will be applied once the cron runs and finds products that meet the rule conditions. The cron runs once a day.
- Manually — rule will be applied once you press the "Apply Rules" or " Save and Apply" buttons.
10. Enable the Remove Products from Other Categories option in case you want products generated by the rule to be removed from their original categories.
11. Enable Remove Other Products from Category option if you want all previously added products to be removed and only new ones to be added to the category.
12. Choose to Use Products from Catalog Price Rules.
Note: when you choose to use them, make sure catalog price rules are active and assigned to the guest customer group.
13. Set the Product Conditions under which products will be automatically added to the chosen categories.
Note: if you don't see the attribute you want to use for dynamic category rule you need to add product attribute to the sales rules conditions.
Set the sorting for the products within the category. Simply select what product attribute to Sort Product In Category By and specify the Direction.
Once you have finished you will be notified about the successful rule creation and see it in the category rules grid. However, you also need to press the Apply Rules button for the rule to be applied immediately, otherwise, you'll need to wait sometime for cron script to apply rules and update categories products.
Note: use the below command if you have an extensive catalog and would like to apply the rules via CLI instead:
bin/magento magefan:dyc:apply-rule