![categories](https://cm.magefan.com/blog/cache/772x_0/magefan_blog/categories2.png)
Categories in Magento are one of the ways to improve navigation and help customers find relevant items faster. Although it's relatively easy to create categories in Magento, it's not so easy to manage.
After you create categories, you need to add products to them manually. It's a long process, especially if you have a lot of categories to group products by. But not for the
Extension.Today we'll prove it to you and create multiple categories in Magento automatically, from scratch. Moreover, these categories will already have products added to them. All you need is a few simple options.
Step 1: Set Basic Rule Information
To start creating your categories navigate to Catalog > Dynamic Category > Rules and press the Add New Rule button.
Here, enable the rule, give it a Name and a Description, and set a Priority. The latter defines how the rule will be processed. The higher the number the later it will be applied.
Step 2: Define the Pattern
First, choose Pattern as a category Type. Then select a Parent Category and set the actual Pattern for the Magento categories you're creating.
Note: the other available type is Static. That's when you create a new category in Magento and then apply the dynamic category rule to it.
Things start to get a little confusing when it comes to patterns. But let's clear them out. There are 2 possible scenarios here.
Multiple subcategories
If you specify the product attribute in double brackets separated by a slash (/), you will get subcategories.
e.g. Pattern: ❴❴brand❵❵/❴❴model❵❵/❴❴version❵❵
where ❴❴brand❵❵ — Apple, ❴❴model❵❵ — Iphone and ❴❴version❵❵ — 12.
As a result, you will get Parent Category > Apple > iPhone > 12 structure.
Single subcategory
The second option is creating a single subcategory.
e.g. Pattern: T-shirt with ❴❴material❵❵ - color ❴❴color❵❵
where ❴❴material❵❵ — cotton or viscose, ❴❴color❵❵ — red or blue.
This will result in the following pattern T-shirt with cotton - color red or T-shirt with viscose - color blue.
To check how your categories will be structured and how many categories will be created press the Preview Categories button.
It allows you to edit the pattern and adjust the attribute values to get the expected result.
Step 3: Set Where and How to Apply the Rule
Here choose the Websites these categories should be long to and specify how to Apply the rule.
- On Product Save — once you save a product (and it falls under the pattern and rule conditions) the extension adds it to a corresponding category.
- Cron — you wait till the corn runs, finds products that meet the conditions and creates categories by the pattern.
- Manually — you press the "Apply Rules" or "Save and Apply" button and categories are created immediately.
Step 4: Fill Out Additional Options
Since you're creating Magento categories automatically, these options don't apply here. However, just in case, here's what happens if you enable them:
- Remove Products from Other Categories — it removes products (added to the pattern categories by this rule) from their original categories.
- Remove Other Products from Category — it removes all products from a category for which you create a rule. We're creating a whole new category from scratch, so it doesn't have any products in it.
- Use Products from Catalog Price Rules — it adds products under a certain catalog price rule to one category. This option works best for the Magento 2 sales category.
Step 5: Define Conditions (Optional)
Once you specify the pattern by which you want to create categories, products already will be added to them (based on the attributes in the pattern). However, if you want to set any other conditions, use a variety of other attributes here.
Additionally, you can set the sorting for the products within the category. Simply choose what product attribute to Sort Product In Category By and specify the Direction.
Step 6: Check Created Categories
Once you finish, hit Save and Apply if you want to see the categories immediately.
Note: creating Magento categories automatically doesn't cover other category options e.g. Search Engine Optimization, Design, Display Settings. So you need to fill these out separately.
However, after you save dynamic categories created by pattern, all of them will appear on the storefront.
Several options, a few minutes, and you create 17 new categories with products added there automatically. New products will be added to these categories automatically too, as long as they meet the conditions set by the pattern.
This significantly improves category management and reduces the manual setup part to minutes. And it's not even the best part.
The variety of attributes available in the conditions allows you to create all kinds of automatic categories — from new arrivals and most rated to shop by brand and best sellers.