Reindexing Magento 2 Tables Using Shell
In this tutorial, I will show you how easy it is to reindex Magento 2 using the command line. For the purposes of this tutorial, we will be reindexing Magento’s New Index Management tables. Let’s begin.
Go ahead and SSH into the site where your Magento 2 installation resides. Once successfully logged into Shell, you can run the following command to shell into the folder where our indexer resides.
cd /home/yourusername/public_html/dev/shell
Now that we are in the folder which contains our indexing script, we will go over the usage for our indexing.
Usage: php -f newindexer.php -- [options]
--status Show Indexer(s) Status
--mode Show Indexer(s) Index Mode
--mode-realtime Set index mode type "Update on Save"
--mode-schedule Set index mode type "Update by Schedule"
--reindex Reindex Data
info Show allowed indexers
reindexall Reindex Data by all indexers
help This help
So, now that we know what the usage for our Magento 2 indexer file is, let’s check the status of our indexer.
php newindexer.php --status
This will tell us if any of our tables needs reindexing.
Finally, let’s reindex all of our New Index Management tables by running the following code.
php newindexer.php reindexall
I really hope this has helped you to better understand how to reindex Magento’s tables in the Magento 2 version. If you enjoyed this tutorial and would like to see more post regarding Magento 2, please leave a comment below.
Saved as a favorite!, I like your blog!
While configuring php shell script, We need to take care of these commands, Abstract.php, Compiler.php, Indexer.php, Log.php. Hope it will help your readers as well as I got help from you.