How to Reindex in Magento 2? (2 Ways That Actually Work)
What Does Reindex in Magento 2 Do?
Reindex means that the index tables in the database are updated and rebuilt. Is it important? These index tables have a direct relation with various front-end operations, including search functionality and product listings. A lack of frequent updates and rebuilding can undermine the customer experience, thereby leading to poor sales.
Whenever data changes in Magento 2, there is a need to update the corresponding tables in the database. However, Magento does not update the tables immediately. Instead, what it does is that it queues all these updates for later. You might be wonder why doesn’t it update immediately?
Since data such as product listings or customer information is continuously changing, frequent updates can undermine the system’s performance. Suppose this happens at a time when your online store is experiencing peak traffic. With poor performance, even your loyal customers won’t have issues shifting to another store.
What Happens If You Don’t Reindex?
When the data is not reindexed after an update, an incorrect data is displayed on the frontend and a lot more slowly. Indexing consolidates the data and speeds up the pitching process. Let’s take an example to understand this point better. Suppose you recently updated the prices for a few top selling products.
However, you did not do reindexing. When customers add the product to their cart, it will either display the old prices or the page will take longer than usual to load. In either case, the customer experience is quite poor. The most likely outcome is cart abandonment and poor word of mouth.
How to Reindex Magento 2?
In this tutorial, we're going to show you two methods that actually work to reindex Magento 2. You can reindex Magento 2 from the backend Admin Panel and also via SSH/ Command Line (CLI) method.
Method 1: Reindex Magento 2 from Admin
Here, reindexing can be done in two modes.- Update on Save: tables are updated immediately after the data is saved.
- Update on Schedule: tables are updated according to a set interval by the cron job.
- Go to System and under Tools, click Index Management.
- Select the checkbox next to each type of indexer to change.
- Select the indexing mode from the Actions dropdown.
- Click Submit.
Method 2: Reindex Magento 2 Via Command Line/SSH
The command line reindexes one time only. To reindex all or selected indexers using this method, connect to your Magento 2 root directory from command line.
a. To Reindex Magento 2 Indexers
- Apply the following command to reindex all or specific indexers.
bin/magento indexer:reindex [indexer]
Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:00 Category Products index has been rebuilt successfully in 00.00.00 Product Categories index has been rebuilt successfully in 00.0.00 Catalog Rule Product index has been rebuilt successfully in 00.00.01 Product EAV index has been rebuilt successfully in 00.00.01 Inventory index has been rebuilt successfully in 00.00.01 Catalog Product Rule index has been rebuilt successfully in 00.00.00 Stock index has been rebuilt successfully in 00.00.01 Product Price index has been rebuilt successfully in 00.00.01 Catalog Search index has been rebuilt successfully in 00.00.00
b. To View the List of Indexers
- Apply the following command.
bin/magento indexer:info
design_config_grid | Design Config Grid |
customer_grid | Customer Grid |
catalog_category_product | Category Products |
catalog_product_category | Product Categories |
catalogrule_rule | Catalog Rule Product |
catalog_product_attribute | Product EAV |
cataloginventory_stock | Stock |
catalog_product_price | Product Price |
catalogrule_product | Catalog Product Rule |
catalogsearch_fulltext | Catalog Search |
c. To View Indexer Status
- Sometimes the reindex command does not update all the indexers so to check the status of every indexer and find out if there is still an indexer that requires to be reindexed, apply the following command.
bin/magento indexer:status
Design Config Grid: | Ready |
Customer Grid | Reindex required |
Category Products: | Ready |
Product Categories: | Ready |
Catalog Rule Product: | Ready |
Product EAV: | Ready |
Stock: | Ready |
Product Price: | Ready |
Catalog Product Rule: | Ready |
Catalog Search: | Ready |
d. To Reindex the Indexers with the Status ‘Reindex required’
In this way, you can reindex individual indexers as well like you can reindex Customer Grid, Catalog Search, etc.- In the above example, the indexer ‘Customer Grid’ needs to be reindexed. The following command will reindex Magento 2 Customer Grid indexer.
php bin/magento indexer:reindex customer_grid
php bin/magento indexer:reindexNow all indexers should be "Ready".
How to Fix One or More Indexers are Invalid in Magento 2?
If your data is not indexed properly, you might get the following error:
One or more indexers are invalid. Make sure your Magento cron job is running.
Solution:
In this case, you need to Reindex Magento 2 via CLI.
Open the Comman Line and go to the Magento 2 root folder, then run the following command:
php bin/magento indexer:reindex
Conclusion
This concludes our article on how to reindex in Magento 2. If you have any issue in Reindexing Magento 2 from Admin, you can contact our support team by submitting a ticket here.
FAQs
What is reindexing in Magento 2?
It refers to the process of updating and rebuilding index tables in the database. The purpose is to reflect the latest changes.
What if I don’t reindex?
If you don’t reindex, latest changes won’t reflect on the store. Your customers will browse incorrect information and contend with poor store performance (e.g. slow loading times). It will undermine your store’s performance and brand image.
How do I know that the reindexing process is successful?
Once the reindexing process is complete, a message saying, “The stock index has been rebuilt successfully" will show up on the screen.
When should I reindex my Magento 2 store?
You should reindex whenever you make significant changes to your store, including product and customer information.
How long does the reindexing process take in Magento 2?
There is no specific time as various factors like store size, data complexity, and changes made need to be considered.
Related Articles:
This blog was created with FME's SEO-friendly blog