On occasions, you may find that Magento isn’t reindexing your tables. You’ll be made aware of this by the “ Reindex Required ” notification under System > Index Management . In this video, I’ll show you how to manually Reindex Magento 2 via the Command Line Interface.
Reindex Magento 2
The purposes of indexing tables within Magento is to improve the performance of the Frontend. The way in which the Magento Database is structured, means that data spans over many tables.
In order to help customers access this information quickly on the frontend of the website, Magento gathers all of the relevant information and puts them into a selection of smaller tables. This is known as Indexing.
So whenever we update information in Magento (such as price for example), we need to ensure that the tables are being reindexed so that they contain the latest updates. This is normally done automatically, but may also be scheduled to take place at specific times of the day.
In a moment, I’ll go over how to reindex these tables manually incase you can’t wait for the next scheduled reindex, or on the rare occasion there is an indexing error.
So, the first thing you’re going to need is access to your web server via an SSH Client. In this example, I’m using Putty for windows.
If you aren’t sure about your login details for your web server, you can always reach out to your web server provider for assistance.
I’m going to connect to my web server and navigate to the directory where I have Magento installed. This location can vary from one installation to another.
Now that I am sitting in my Magento root directory, I can start running the commands I need to reindex the tables. I can tell that I’m in the root directory of Magento, because when I type ls -l and hit enter, I can see all of the core files in the current directory.
A little tip: If you’re feeling overwhelmed by all of the text in the window, then you can always type ‘clear’ followed by enter. This essentially scrolls up the screen, hiding all of the previous text. You can still scroll up with your mouse to see the history if you need.
There are several Index related commands that I can use for Magento, and so I’ll go over them one by one. Also, depending on your server setup, you may have to prefix your commands with ‘php ‘ in order for them to work.
By typing ‘bin/magento indexer:info’ and hitting enter, you can view all of the available tables that can be indexed. On the left if the reference and on the right is the label.
We can also type ‘bin/magento indexer:status’ followed by enter to view the status off all the indexes. This output might tell you if the an Index table is Ready and up-to-date, or whether is needs reindexing.
On a side note, you can also view the status of an individual table by adding the table reference on the end of the command. So, if I type ‘bin/magento indexer:status cataloginventory_stock’ and hit enter, I can just see that table.
Another command we can use is ‘bin/magento indexer:show-mode’. This will show a list of our tables on the left, followed by the current mode that they are in on the right.
I could also check the mode of a single table by typing ‘bin/magento indexer:show-mode catalog_category_product’.
So, in order to reindex our tables we only need to type ‘bin/magento indexer:reindex’ and hit enter. This will go through each of the tables and index them. This can take several moment depending on how much data you have in the database.
We could also reindex individual tables by adding the table reference on the end of the command. So, to reindex the price table, I would simply type ‘bin/magento indexer:reindex catalog_product_price’.
Finally, we can actually change the modes of our tables from here as well. So, if I want to switch Catalog Search to ‘Update on Save’, I’d simply type ‘bin/magento indexer:set-mode realtime catalogsearch_fulltext’. And to switch it back to ‘Update by Schedule’, I’d type ‘bin/magento indexer:set-mode schedule catalogsearch_fulltext’.
So, I hope you found this video useful. If you did, be sure to hit that Like button. And for more Magento Tips and Tutorials, be sure to subscribe and hit the bell notification to be alerted when new videos are uploaded. For more on