Magento 2, PHP

Magento 2: Reindex Using Command Line

1. Connect to your Magento 2 installation in the root of your project.

usually in public_html or under yourmagentoinstallation.com/html

 
2. Reindex all Magento 2 indexers using below command:

php bin/magento indexer:reindex

You will receive a similar result as presented below:

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:01
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:01
Catalog Product Rule index has been rebuilt successfully in 00:00:00

3. Check the status of the indexers and identify indexers that still need to be individually reindexedsometimes general reindex does not work for all indexers

php bin/magento indexer:status

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

4. Show the list of the indexers and corresponding indexer id that need to be used for individual reindex.

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

5. Reindex each indexer that has status “Reindex required using below command:

php bin/magento indexer:reindex [catalog_category_flat]
Example: php bin/magento indexer:reindex catalogrule_rule

6. Check again the status of the indexers using the command from step 2, now all indexers should be “Ready”.

Tags :