Configure Magento 2 Reindex via Command-line and Admin Panel
Magento 2 Reindexing is essential for enhancing your store's performance and ensuring the accuracy of your e-commerce data. By regularly refreshing your data, you can minimize customer wait times and boost your conversion rates.
In this tutorial, we'll provide a detailed, step-by-step guide to reindexing using both command-line and backend interface methods. It will help you streamline the reindexing process, ultimately maintaining a fast and efficient shopping experience for your Magento 2 store.
Key Takeaways
-
Discover the significance of Magento 2 reindexing in optimizing Magento performance and efficiency of your Magento 2 store.
-
Learn how to reindex Magento 2 using the command-line method by running specific commands in SSH or CLI.
-
Learn how to reindex using the Backend Interface of Magento 2 to keep your indexes up-to-date.
-
Recognize the challenges of reindexing, particularly for large stores, and discover resources to overcome them.
Method 1: Command-line Reindexing
To reindex your Magento 2 store using the command line method, follow these steps:
-
Log in to your store using SSH or Command Line (CLI).
-
Navigate to the root directory of your online store (usually in public_html or under yourmagentoinstallation. com/html).
-
Run the command
php bin/magento indexer:reindex
- You will receive the following result:
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:00:00
Product Price index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:01
Catalog Search index has been rebuilt successfully in 00:00:01
Stock index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Checking and Managing Indexes in Magento 2
Magento 2 provides a set of useful reindex commands that are important in optimizing your online store's performance. Below is a list of these commands:
Command | Shortcut | Function |
---|---|---|
bin/magento indexer:info |
bin/magento indexer:info |
Displays a list of all indexers. |
bin/magento indexer:status |
bin/magento i:sta |
Views the status of all indexers or a specific indexer. |
bin/magento indexer:set-mode |
bin/magento i:set |
Reindexes all indexers or a specific indexer. |
bin/magento indexer:reindex |
bin/magento i:rei |
Invalidates all indexers or a specific indexer. |
bin/magento indexer:show-mode |
bin/magento i:sho |
Views the current configuration of indexers. |
- Check the indexer status using:
php bin/magento indexer:status
- Next, check the status of the indexers and identify those requiring individual reindexing. Use the command:
php bin/magento indexer:status
- The result will show as follows:
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
Note: General reindex does not work for all indexers.
- Use the following command to view the list of indexers and their corresponding indexer IDs required for individual reindexing:
php bin/magento indexer:info
- You will receive a similar result as presented below:
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
- To reindex selected indexers marked as Reindex required, execute the following commands:
php bin/magento indexer:reindex catalog_category_flat
Example:
php bin/magento indexer:reindex catalogrule_rule
php bin/magento indexer:reindex design_config_grid customer_grid
php bin/magento indexer:reindex catalog_category_product
php bin/magento indexer:reindex catalog_product_category
php bin/magento indexer:reindex catalog_product_price
php bin/magento indexer:reindex catalog_product_attribute
php bin/magento indexer:reindex catalogsearch_fulltext
php bin/magento indexer:reindex cataloginventory_stock
php bin/magento indexer:reindex catalogrule_rule
php bin/magento indexer:reindex catalogrule_product
- After reindexing, verify the status of the indexers using:
php bin/magento indexer:status
- All indexers should now display as Ready.
Additional Indexer Commands for Command Line Reindexing
1. To Reset the Indexer Status to Invalid
You can set the indexer status to invalid in Magento 2 by running:
php bin/magento indexer:reset
2. To Show Index Mode
To view the current index mode in Magento 2, run the following:
php bin/magento indexer:show-mode
The following result will be:
$ php bin/magento indexer:show-mode
Design Config Grid: Update on Save
Customer Grid: Update on Save
Category Products: Update on Save
Product Categories: Update on Save
Product Price: Update on Save
Product EAV: Update on Save
Catalog Search: Update on Save
Stock: Update on Save
Catalog Rule Product: Update on Save
Catalog Product Rule: Update on Save
3. To Set Index Mode Type
You can set the index mode type in Magento 2 by running:
php bin/magento indexer:set-mode {realtime|schedule} [indexer]
For example:
magento indexer:set-mode schedule catalog_category_product catalog_product_category
Method 2: Admin Panel/ Backend Interface Reindexing
Reindexing in Magento 2's admin panel offers two modes:
-
Update on Save Mode: In this mode, the index tables immediately update when dictionary data changes. It captures changes immediately after any save action, leading to prompt index updates. The index management page also updates and flushes reindex messages.
-
Update by Schedule Mode: This mode schedules index updates using a cron job. It defines intervals for reindexing and writes updates to the index during Magento cron job execution.
To reindex through the admin panel in Magento 2, follow these steps:
-
Log in to the Magento 2 Admin Panel.
-
Navigate to System > Tools > Index Management category in the admin panel.
-
Select the Checkbox next to each type of indexer you want to modify.
-
From the Action List, choose the Indexing Mode.
-
Finally, click the Submit button to apply the selected mode to the indexers.
Optimizing the Magento Default Reindexing Process
Reindexing in Magento 2 can be complex, particularly when using the default method. This process can be time-consuming and lead to slower storefront performance.
It also requires technical expertise and access to SSH or CLI, which can be challenging for store owners lacking coding experience. To overcome these challenges and optimize the reindexing process:
1. Schedule Off-Peak Reindexing
Analyze your store's analytics data to determine the hours or days when customer activity is lowest. Use this information to create a reindexing schedule that aligns with these periods. Automate the scheduling process if possible to ensure consistency.
2. Choose Indexing Modes
Assess your store's needs and priorities. If you need real-time updates, choose Update on Save. If performance is a higher concern, consider the Update by Schedule mode, which spreads out indexing tasks over time. Experiment with both modes to find the best fit for your Magento ecommerce.
3. Explore User-Friendly Tools
When exploring Magento extensions or tools tailored to your Magento version, conducting thorough research is essential. Begin by reading user reviews and seeking recommendations within the Magento community. Prioritize solutions that offer clear documentation and reliable customer support.
4. Monitor and Address Failures
Establish monitoring alerts to receive real-time notifications of reindexing failures. When a failure occurs, investigate the root cause. It involves checking your server setup, ensuring correct Cron Jobs configuration, and resolving any underlying issues. Document and analyze recurring failures to implement long-term solutions. Refer to the official Magento documentation for more information on reindexing in Magento 2.
FAQs
1. What does it mean to reindex Magento 2?
Reindexing Magento 2 involves refreshing various data elements within the System. These elements include product prices, catalog search indexes, and more. This process aims to ensure that your online store remains current and up-to-date.
2. Are there any messages that show successful re-indexing of Magento 2?
When Magento 2 reindexes, it will display a message saying, "The stock index has been rebuilt successfully." It helps provide information about the specific parts updated during the re-indexing process.
3. Do I need a cron job for indexing in Magento 2?
Yes, a cron job is essential in Magento 2 indexing, automating updates, and ensuring the currency of all indexes. It also ensures that your store's data remains up-to-date and accurate.
4. Can Magento index categories?
Yes, you can index categories in Magento using the category products index. This process helps establish the relationship between categorized items under the catalog_category_product index.
5. What happens if my re-index fails?
Verify your server setup if you get the “index required” message. It is important to ensure you have correctly configured all Adobe Commerce and Cron Jobs settings.
v
6. How to fix one or more invalid indexers in Magento 2?
To fix an invalid indexer, reindex Magento 2 via CLI. Open the Command Line and go to the Magento 2 root folder. Next, run the following command:
php bin/magento indexer:reindex
Summary
Magento 2 reindex notifies search engine bots about new and updated launches on your website. It ensures that your customers consistently access the latest updates on your Magento store. This tutorial provides a step-by-step guide to reindexing methods in Magento 2: command-line and backend interface. It also offers insights on optimizing the Default Reindexing Process.
Ready to optimize your ecommerce store for better SERPs? Explore Magento hosting plans designed for optimal performance of your Magento 2 store.