How to re-index Magento data?

Updated on December 9, 2021

1) What is Indexing?

The arrangement of data according to a specified schema or design is referred to as indexing. Indexing is the process of generating an index for a database structure to improve data retrieval. It is used in various contexts, including, among other things, making information more attractive and accessible.

This form of indexing is also known as Web indexing. Indexing helps in making searches less time-consuming – without an index, the search engine would have to equally search every document at its disposal. In contrast, an index eliminates most of this effort.

2) What is Magento Indexing:

Indexing is the process through which Magento converts data like products and categories to enhance your storefront’s efficiency. The converted data must be updated or reindexed when data changes.

Magento has a complex design that maintains a large amount of merchant data in several database tables. Magento uses indexers to collect data into specific tables to enhance storefront performance.

3) Why we need Magento Indexing:

Magento stores many products, users, categories, pricing, product attributes data, etc., in database tables. To optimize web store performance, Magento has to transform data into special tables using indexers.

For example, if you change the price of your product – say from $31.81 to $21.40, or add new products, Magento would need to re-index to display this data on the frontend store.

Without indexing, Magento would have to compute every product’s price on the run, taking into consideration shopping cart price rules, bundle pricing, discounts, tier pricing, and so on. Similarly, for products within subcategories or inventory calculations. Imagine this happening in a store with thousands of products on each page load. Indexing allows Magento to store this data in a quick-loading way with most of the calculations already built-in.

4) Different approaches to achieve the indexing/re-indexing:

a) Re-index from Magento Admin:

Important Note: It is not recommended to re-index the Magento application through admin as sometimes not all the indexers get re-indexed from this method.

Step # 1:

First, access the admin panel of the Magento application. Once you are inside, then follow the below path:

Go to SYSTEM > (Inside the “tools” section), select the Index Management, and check the indexers status.

Go to SYSTEM then select the Index Management

Step # 2:

Now put the check on the items in this list that are showing “Reindex required” inside the status section and go to the “Actions” tab and then select from the tab to “Update on schedule.”

This will start a reindex for selected indexers.

Important Note: Sometimes, not all indexers are reindexed using admin reindex even if time & date is showing as updated in Magento admin. We recommend double-checking the reindex process using the SSH/CLI reindex method presented below.

Now put the check on the items in this list that are showing “Reindex required

Reindex mode: You can also set your indexers as “Update on Save” if you want to store entities indexed when saving admin configurations. Else you can select “Update by Schedule,” and indexers will be reindexed recurrently (default once / day). Ensure your cron tasks function correctly on your server for “Update by Schedule” to work correctly.

b) Executing the re-indexing from CLI:

Step # 1:

First, make the connection of the server via SSH. Kindly follow our knowledge base article on how to connect your application via SSH and SFTP.

Step # 2:

Now run the following command to access the webroot of the application.

cd applications/application_folder_name/public_html/

Step # 3:

First, check the status of index if required.

php bin/magento indexer:status
check the status of index if required

Now run this command to reindex the application data.

php bin/magento indexer:reindex

Output:

You will get the same result as shown below:

run the command to reindex the application data.

Step # 4:

Verify the status again of the indexers and identify indexers that still need to be individually reindexed, as sometimes, general reindex does not work for all indexers. Run the below command to check their status again.

php bin/magento indexer:status

Output:

You will receive a similar result as presented below:

Design Config Grid:
Ready
Customer Grid:
Ready
Category Products:
Ready
Product Categories:
Ready
Product Price:
Ready
Product EAV:
Ready
Catalog Search:
Ready
Stock:
Ready
Catalog Rule Product:
Reindex required
Catalog Product Rule:
Ready

Step # 5:

Now we will need to list out the indexers’ corresponding indexer ID to reindex them individually.

php bin/magento indexer:info

Output:

You will receive a similar output.

design_config_grid
Design Config Grid
customer_grid           
Customer Grid
catalog_category_product    
Category Products
catalog_product_category
Product Categories
catalog_product_price
Product Price
catalog_product_attribute
Product EAV
catalogsearch_fulltext
Catalog Search
cataloginventory_stock
Stock
catalogrule_rule
Catalog Rule Product
catalogrule_product  
Catalog Product Rule

Step # 6:

Please make sure to run the reindex command to all the indexers, which show reindex required.

At the moment, the following indexer ID “catalogrule_rule” required the re-indexing. So the command will be the following:

php bin/magento indexer:reindex catalogrule_rule

Step # 7:

Now recheck the status of the reindexing to ensure all the re-indexing has been completed by using step#4.

Conclusion:

When we install the Magento application by default, the cron is updated for this application, automatically re-indexing if required. If you are facing the issue of re-indexing, then this guide has covered all the steps. But still, if you are not able to resolve this issue, you can contact our support team to provide further assistance on it.

Need More Help!

Type in your question at the knowledge base website or comment below

Leave a Comment

Your email address will not be published. Required fields are marked *