How to use the Dynamic Category extension for Magento 2?
When using Magento default installation, products can only be assigned to categories manually.
With Dynamic Category, products can be dynamically assigned to categories based on product attributes.
This extension allows you to define product conditions (general and special conditions) for each category, as well as custom product positions and to select matching products.
Follow this guide to know how to use the Dynamic Category extension.
STEP 1: Define conditions on the categories
With Dynamic Category you can define your own conditions from:
Select the category for which you want to define conditions and go to:
Products in CategoryProduct Category Rules
With Dynamic Category, you can define conditions based on product attributes.
Click on + in the Product Category Rules sub-tab.
From the product attributes list, select the attribute you want to create a condition for (color, size..).
Attribute Set is Clothing
Finally, click on REFRESH MATCHING PRODUCTS to get the list of all the products matching the condition.
Besides the product attributes conditions, Dynamic Category comes with very useful additional conditions that allow you to customize product conditions easily.
- Product type
You can define a condition based on product types.
You can select one or multiple product types for matching products.
Product Type is one of Simple Product, Virtual Product, Downloadable Product
- In promo
This condition uses the product price index table populated by Magento when the indexation process is over.
It verifies if any modification has been made on the product price through either catalog price rules or special prices.
In the case of promotions (catalog price rules), the reduced price will appear only on the frontend.
In Promo is Yes
- Special price applied
Unlike the condition above, this one only verifies if a special price has been applied to the product for a specific period of time.
Therefore, any other price reduction or modification won't be included (for ex: catalog price rules).
Special Price Applied is Yes
- Total child products quantity in stock
It is sometimes
usefulto filter configurable or grouped products by the quantity their assigned simple products have in stock.
Note that each simple product quantity is added to its parent product.
Total Child Products Quantity In Stock is 10
- Replace matching simple products by parent products
Thanks to this condition you'll be able to replace a simple product with its parent, which will then retrieve the attributes previously stored in the simple product.
Regarding simple products that don't have any parent (orphan products), you'll be able to either keep or discard them.
Replace Matching Simple Products By Parent Products and Keep Orphans
STEP 2: Import category rules
In the case where you’ve already created rules for a category and would like to assign those same rules to another, you can directly import them via the Import Category Rules tab.
All you need to do is to choose among the categories the one you want to retrieve the rules for and then click on Import.
In the Product Category Rules sub-tab will be displayed the conditions, which you'll be able to edit.
STEP 3: Index and refresh the matching products
For better performances in the frontend, products that match conditions are indexed in the native Magento database table.
Products are then retrieved in the frontend just like Magento default behavior and in the order that you have defined in the backend.
Because products may not match the defined conditions anymore (attribute has changed, the
You have 2 ways of reindexing your products:
You can manually index your products and categories from your Magento backend in:
From a command line
You can also easily refresh all matching products manually by running the below command line:
Note that the indexation is launched after the command line is run.
The matching products are indexed for performance purposes.
Then, if a product does not match the defined conditions anymore, you’ll have to wait until the scheduled task is over (by default: every 24 hours) for the product to be removed from the list.
You can change the index settings in:
- Automatically Reindex Matching Products
Activate that option to reindex the matching products via a scheduled task.
- Reindex Matching Products Every
Define the frequency of the automatic indexation in hours.
- Enable Category Reindexation Logging
Activate to enable the categories indexation logging.