Hello to all Magento practitioners!
I guess you are continuously wondering about the ways to make your large e-store faster and more customer-friendly. Well, you’ve landed in the right place. In this article, I’ll tell you about a relatively painless way to make a Magento 2 store perform better by setting Flat Catalog. As we know, Magento 2 slowdown (or drop in system performance) is one of the challenges large e-stores face.
So, let’s dive in.
DO YOU HAVE MAGENTO 2.3.0+?
INCREASE THE LOADING SPEED VIA JS OPTIMIZATION!
GET OUR FREE GUIDE WITH 4 TECHNIQUES.
Magento 2 weak performance: the why?
Magento uses the Entity-Attribute-Value (EAV) catalog by default. What does it mean for regular system users? This means that 1 product having, say, 6 obligatory attributes is stored in 6 different tables (the same goes for categories).
This is how it looks:
You see, it resembles a well-baked juicy hamburger that exceeds the “eating capacity” of the majority of human beings.
‘How come?!’, our respected reader will exclaim, ‘This is counterproductive!’ Couldn’t agree more, as swollen databases hurt the e-store performance.
To fight this threat, Magento 2 experts developed 2 special features:
- Use Flat Catalog Product
- Use Flat Catalog Category
Magento 2 Flat tables: what are they?
A Flat catalog is an additional table storing all information about a product or categories in Magento 2 store. Working principle here is fairly simple: the shorter the query to the database, the better the store performance. That’s it, we’ve freed the rabbit from the hat. You think it’s time to leave? Hold on, I’ll tell you how our cute fluffy friend got there.
Here is a step-by-step instruction on how to enable Magento 2 Use Flat Catalog Product and Use Flat Catalog Category. Navigate to: Store > Configuration > Catalog > Storefront > Use Flat Catalog Category or Use Flat Catalog Product = YES:
If you address the database now, you’ll see a table uniting numerous attributes; the same works for categories. The system will digest this ‘dish’ much faster, it’s not that choky hamburger!
What has changed in the work of the system, optimized database query aside? Now Flat tables update every minute or according to your preferred Cron settings.
Let’s test the work of enabled Magento 2 Flat Catalog step by step.
We’ll test it on a simple product:
- Open the simple product page.
- Now let’s change the product name. I like the name Amasty. Surprised?
- Now save the changes clicking Save.
- Then find the modified product via flat catalog product using the Magento 2 catalog search function in the frontend.
Expected result: automatic update will allow you to see the changes in a minute (or according to your Cron settings).
If your Cron doesn’t follow the ‘here and now principle’, you could use the command for manual Cron activation:
php bin/magento cron:run
Voila! Now that your Magento performance has improved and the whole system shines and sparkles, you may well wonder, ‘If Magento 2 Flat Catalog is simpler/more performance-friendly, why not use it by default?’
This question has puzzled many clever people, and I’m not an exception. The Internet offers an endless variety of answers. As I value your time, I offer you the three versions that I like most. Besides, experts say they are valid. So here they are:
- Reason #1. A limited number of product attributes (categories) in a table.
- Reason#2. EAV catalog is far more flexible, so it gives developers a lot more room for action.
- Reason #3. In practice, if you have 5 stores that sell 300 products in 10 categories, the difference between EAV and Magento 2 Flat catalog will be significant. Imagine the situation: an insect flies some 100 m away, and you are trying to guess what insect it is, a fly or a mosquito. The thing is, using Flat catalog pays off only when your large Magento 2 system performance is going down, and to notice it, you should run your system performance testing regularly.
Flat table for testing your store
So we’ve just figured out that Magento 2 Flat table catalog proves most effective for dealing with large (information-intense) databases. You are likely to have a staging site with some modules that you bought at amasty shop (at least I hope so). Now you want to test your Magento 2 Flat table catalog performance under load and with regard to the installed modules.
To set up a basic test, follow the step-by-step instruction below.
Roll out a Magento 2 solution relying on a large database. To do so, follow this guide. Don’t forget to choose a relevant store profile. This will help you generate an adequate amount of data for your store depending on its size – large, medium or small.
Choose one or several suitable modules and install them. For example, you can choose:
- Magento 2 Mass Product Actions that enables you to change product attributes directly in the product grid. This saves a lot of time, which is important in testing;
- Magento 2 Duplicate Categories that will help you test a Flat catalog category using changes in the group of categories under different conditions.
Go to command line and turn on cache: php bin/magento cache:enable
Run the command: php bin/magento index:reindex
Activate in Magento 2 Admin Panel Use Flat Catalog Product and/or Use Flat Catalog Category.
Now your store is ready for testing with Magento 2 Flat Catalog.
Thinking of the fact that speed is the first impression you make on your potential customers, you’re going in the right direction. We, in turn, help you overcome the obstacles with our powerful pagespeed modules.
One of the newly released solutions is our Magento 2 Speed Optimization extension. Say, your Magento score in Google PageSpeed Insights is something like 46. You want to overcome the slow site and top it to 90.
How to do it? Just enable our speed optimization extension. Among the killer features are: (a) lazy load, (b) minifying of HTML, CSS, JS, (c) moving JS to the footer, (d) images optimization without affecting the quality, etc.
To crown it all
Magento 2 is a productive and flexible platform. Well, it does host numerous difficulties, secrets, and subtleties, but as you gradually learn them, you’ll be able to turn your Magento 2 and its stores into a well-performing and stable system.
Still have questions? Feel free to pose them in the comments below.