Magento 2 Reindex: manual reindex from the admin panel or a cron job

What is Magento 2 index

Due to the sophisticated architecture, Magento gathers a lot of merchant’s data, e.g.: catalog info, prices, users, stores, in many database tables. To optimize the frontend performance the most important information is stored into special tables using indexers that gathering the data. You need to keep the indexes up-to-date to show actual data on the storefront. 

When Magento 2 reindex is required

In Magento 2 reindex is required for these 8 indexers when any changes are made:

E.g.: when updating a product price the data should be reindexed to be correctly displayed on the frontend. The indexation sufficiently reduces time spent on calculating a final order price including cart price rules, bundle pricing, discounts, tier pricing, etc. 

  1. Category products;
  2. Product categories;
  3. Product price;
  4. Product entity attribute value;
  5. Stock;
  6. Catalog rule product;
  7. Catalog product rule;
  8. Catalog search.

In older Magento versions indexation is dependent on the indexer.php file placed under the shell folder. In Magento 2 it’s managed by the bin/magento instead.

How to reindex Magento 2?

To reindex indexes in Magento 2 you can use several ways: reindex via a cron job and use manual reindex from the admin panel.

Reindex via a cron job

Reindex Magento 2 via a cron job is very convenient way. In this case reindexing runs every minute (you can set an appropriate period) eliminating the necessity to manage the process manually . To configure a cron job correctly follow the guide.

Manual reindex from the Admin Panel

You can use Magento 2 manual reindex via the command line:

  • Log in to your Magento server admin panel as the file owner;
  • Use the next option:php bin\magento indexer:reindex where [indexer] is a space-separated list of indexers;
  • The option is suitable for reindexing all the store: php bin\magento indexer:reindex. In this case, you’ll see the corresponding results:

reindex-results-magento

However, reindexing of all indexers can take long, therefore, you’d better manage a cron job for the issue.

  • If you  want to see the list of all indexers, type in: php bin\magento indexer:info. Here you can find the name of a definite indexer, which is to be further reindexed through the command: php bin\magento indexer:reindex indexer_name (the name of a desired indexer is applied to the ‘_name’ part). 
Rate the answer?