Magento 2 Reindex / Indexer Usages via Command Line

In this tutorial, we will talk about Reindex / Indexer Usages via Command Line in Command Line Series. As you know, from Magento 2, they add many commands in bin/magento. This may difficult to get approach this , let me explain more detail about it.

Let show all reindex usages

php bin/magento indexer --help

It will show the following:

indexer                                                                                                                     
 indexer:info                              Shows allowed Indexers                                                           
 indexer:reindex                           Reindexes Data                                                                   
 indexer:reset                             Resets indexer status to invalid                                                 
 indexer:set-mode                          Sets index mode type                                                             
 indexer:show-mode                         Shows Index Mode                                                                 
 indexer:status                            Shows status of Indexer  

Indexer command line

Check indexer status by the following command

php bin/magento indexer:info

We will get result:

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
How to Reindexe Data
php bin/magento indexer:reindex
How to Reset indexer status to invalid
php bin/magento indexer:reset
How to Show Index Mode
php bin/magento indexer:show-mode

Result:

$ 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
How to Set index mode type
php bin/magento indexer:set-mode {realtime|schedule} [indexer]

E.g:

magento indexer:set-mode schedule catalog_category_product catalog_product_category

Enjoyed the tutorial? Spread it to your friends!

magento-2-module-development
command
line
cli
console
indexer
reindex

Sam Thomas
Sam Thomas

CEO and Founder of Mageplaza. Pursueing a simple and healthy lifestyle. A friend, a husband and a dad of two children, a trainer and a wanna-be influencer. He is a big fan of sports and travel, also.