How To Fix “One Or More Indexers Are Invalid” Error In Magento 2?

No comments

Have you been in a situation where you were working on Magento 2, and then a system message showed “One or more indexers are invalid. Make sure your Magento cron job is running.”? If this is your first time having this issue, you might not know what to do. Then you can follow this guide to resolve the problem quickly.

indexers are invalid

What Are Magento Inderxers and Cron Job?

Indexers

Magento 2 is a platform built to optimize the performance of e-commerce. Thus there’s a lot of data stored in its database – catalogs, prices, users, etc. So every time you make changes, the system will begin the indexing process to update any adjustments in the database. The indexing process will distribute data to the special tables to improve your store’s performance.

Cron Job

Cron Job is a critical feature in Magento 2. Its mission is to generate commands so that activities can automatically occur at the set time in the future. Some activities that require cron jobs are:

  • Catalog price rules
  • Newsletters
  • Generating Google sitemaps
  • Customer Alerts/Notifications (product price change, product back in stock)
  • Reindexing
  • Private sales (for Magento Commerce)
  • Automatic updating of currency rates
  • All Magento e-mails (including order confirmation and transactional)

As you can see from the list, reindex also requires the role of corn job. So if it isn’t working correctly, the indexing process will be delayed.

Fix “One Or More Inderxers Are Invalid” Error In Magento 2

To help the system run smoothly after the updates in the database, we need to check if the reindex mode and the cron job are correctly set.

Select the reindex mode

Step 1: Go to Admin, choose System > Index management

Step 2: Select the Indexer you want to reindex. Or you can select all if you aren’t sure what to be reindexed.

Step 3: Expand the Action menu, select the action you want to apply to the selected indexers. 3 types of action you can choose are:

  • Update on Save
  • Update by schedule
  • Invalidate index

Run the command for reindex

  • Use this command to see all indexers in Magento 2:
php bin/magento indexer:info
  • To reindex all the indexers in Magento 2, use:
php bin/magento indexer:reindex
  • To reindex only one specific indexer:
bin/magento indexer:reindex [indexer]

E.g., To reindex only customer_grid, use

bin/magento indexer:reindex [customer_grid]

Check and run cron jobs

By default, Magento 2 will create cron jobs to reindex indexers

#~ MAGENTO START
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run | grep -v Ran jobs by schedule >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log
#~ MAGENTO END
  • If the cron jobs for Magento 2 is missing, then you need to reinstall them:
php bin/magento cron:install
  • To run all Magento 2 cronjobs, use this command:
php bin/magento cron:run

After finishing all these steps, return to the Index management sector. You should see that all indexers’ statuses have been changed to Ready.

indexers in magento 2

Go back to the dashboard, close the pop-up message “One or more indexers are invalid. Make sure your cron job is running properly” message. Refresh the page, and the message should not appear again now.

Conclusion

Indexers and cron jobs are essential players that ensure your Magento system runs smoothly. Hopefully, after reading this tutorial post, you know how to efficiently deal with the issue of indexers that are not valid.

Besides the invalid indexers, there are more common issues that you might confront in your Magento site, such as You Don’t Have Permission To Access On This Server, The Promotional Code You Entered Is Not Valid, Exception Printing Is Disabled By Default For Security Reasons,… To get the right solutions for all of these, make sure to follow Tigren’s blog!

Heiley NguyenHow To Fix “One Or More Indexers Are Invalid” Error In Magento 2?

Related Posts

Leave a Reply