Magento 2 Index Management is stuck! What do I do now?

Photo by Mark König on Unsplash

Magento 2 Index Management is stuck! What do I do now?

Introduction

So I was working away on a website when a support ticket landed on the helpdesk. It was a client complaining that her products on her Magento 2 website had ALL been marked as out of stock. You could sense the panic from the client. During a busy period where stock is selling, this problem just cropped up from out of nowhere.

Magento Index Management

Below is a brief description of what index management is and what this does on the website. This is a snippet taken from the Magento User Guide found here;

Magento reindexes automatically whenever one or more items change. Actions that trigger reindexing include price changes, creating catalog or shopping cart price rules, adding new categories, and so on. To optimize performance, Magento accumulates data into special tables using indexers. As the data changes, the indexed tables must be updated — or reindexed. Reindexing is performed as a background process, and your store remains accessible during the processes.

So you can see just how important it is for the indexers to be working on the Magento website. If the indexer is not updating stock levels or price rules, it could result in products being sold at the wrong advertised price, some new products not appearing, categories not showing up. Make sure that all the indexer statuses are appearing in green. Below is an example of the indexers appearing fine.

1 PUOWRZV64u9UYYPYuc8WeQ.jpeg

What steps did you take next?

At this point I was left scratching my head, thinking what to do next. The client was manually updating the stock statuses, something that would have taken an age even if there were several people working on the site at one time. My first thought was to run the clean and flush cache commands via SSH.

Here are the commands that were used via SSH;

php bin/magento cache:clean
php bin/magento cache:flush

Simple enough right? Not quite! Now at this point, even I started panicking a little. I’m the one that should be calm through this. I guess that wasn’t the case!

Then I decided to run the indexer command, I was confident that this would resolve the problem the client was having with the stock statuses showing as “Out of stock”

php bin/magento indexer:reindex

So did that resolve the problem, panic over?

Nope, that did not resolve the problem for the client. At this point, I was scratching my head even harder, any more head-scratching and I’d end up going bald. I kicked the panic to one side, took a deep breath & said to myself that I’m going to resolve this problem before I do anything else.

I came across a command that I didn’t see when looking at the documentation for Magento 2 — I know the commands to clear the cache and flush it from the top of my head, publishing content is fine, running the indexer no problem, but this one command slipped through the net for me. This was the command that would save the hair on my head and kill off the panic for the client.

php bin/magento indexer:reset

Oh, you beauty! Running the command in my terminal and flushing the cache sorted this issue out. Turned out that the status column under Index Management was showing as “Processing” for some of the indexers. This is definitely one command I won’t ever forget. It’s etched in my brain now.

I hope this experience will come in handy for someone that may be in the same situation that I was in. Now I can’t guarantee that the problem I came across will be the same one you’ll experience.

I need a coffee now. Phew. Is anyone willing to brew up for me?