WHAT IS FLAT CATALOG IN MAGENTO 2?
As you might know, there are 2 data models in magento 2, namely EAV Catalog and Flat Catalog.
- EAV Catalog: On one hand, the EAV Catalog is an entity attribute value database model. Every column data value is stored in their corresponding data type table. Moreover, the EAV Catalog allows us to add as many custom attributes as possible. However, the thing is that since the product attributes are stored in various tables, so as to get the data it will take a lot of time as well as trigger many actions. As the result, it might affect negatively to your store performance.
- Flat Catalog: The Flat Catalog on the other hand, has to use only one table. More specifically, it will take all product attributes in a multi-column table and be updated automatically based on your cron job.
Advantages of using Flat Catalog: Enhancing the speed of catalog and cart price rules process. In other words, it will contribute to boost your performance.
HOW TO ENABLE FLAT CATALOG IN MAGENTO 2?
1st step: Navigate to the Catalog
Go the Admin Panel, navigate to STORES and choose Configuration (under Settings)
(Admin Panel => STORES => Configuration)
On the left panel, please tap CATALOG and select Catalog in the dropdown.
2nd step: Enable Flat Catalog
Firstly, you must expand the Storefront section.
Secondly, uncheck the box Use system value next to the Use Flat Catalog Category and set it to Yes.
Thirdly, you must also set the Use Flat Catalog Product to Yes.
Finally, save the config after you finish.
3rd step: Refresh Cache
There will be a message that requests you to refresh the cache.
HOW TO CHECK THE RESULTS ON THE FRONT-END?
There are 2 methods to see the results, one for a single product and the another for multiple products. We will show you both of them.
Checking the results for the single product
Go the Admin Panel, navigate to PRODUCTS and choose Catalog (under Inventory)
(Admin Panel => PRODUCTS => Category)
Choose a product you want to edit (double-click on it or click on Edit button)
Add the tail “_DEMO” to the product name as the following and then save it.
Now, you can access your homepage, search for the product you have edited as well as browse that item through navigation menu to make a comparison.
Checking the results for multiple products
Go the Admin Panel, navigate to PRODUCTS and choose Categories (under Inventory)
(Admin Panel => PRODUCTS => Categories)
Next, in the category tree on the left, choose any category, then click on the Add Subcategory button. After that, set the category name (e.g.: Test).
To continue, let’s expand the Products in Category section, and check on the product(s) you want to add to the new category. Finally, save the new category.
Once again, to see the result, you must come back to your homepage and search for the new category in the navigation menu.
We have shown you basic definition of the flat catalog in Magento 2 and more importantly, how to set up and check its results on your storefront. If you have any problems when following this tutorial, be free to ask us by leaving a comment below. See you in the next tutorial!
See More Our Magento “How To” Series: