What Is The 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 its 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 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 boosting your performance.
How To Enable A Flat Catalog In Magento 2?
Step 1: Navigate to the Catalog
Go to 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.
Step 2: 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.
Step 3: 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 other for multiple products. We will show you both of them.
Checking the results for the single product
Go to 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 the 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 the navigation menu to make a comparison.
- Checking the results for multiple products
Go to 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 the 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 the 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: