community-features icon indicating copy to clipboard operation
community-features copied to clipboard

Enable Reindexing from Admin Panel

Open mbrinton01 opened this issue 6 years ago • 3 comments

Originally recorded in MAGETWO-87804

Requires Merchant Documentation: Yes

Proposed Release Note:

This feature allows merchants to reindex specific indexes from the Admin Panel. Before this feature, reindexing was only possible from the command line.


:bulb: Initial feedback for story provided by Solution Partner Something Digital

Card:

As a merchant I want to reindex one or more indexes from the Admin Panel so that I can update my site content without having to use the command line or contact a developer.

Background:

In Magento 1, it was possible to reindex one or more indexes from the Admin Panel. This feature was deprecated from the Admin Panel in Magento 2, and it's only possible to reindex sites from the command line using the following commands:

Command Description
indexer:info Shows allowed Indexers
indexer:reindex Reindexes Data
indexer:reset Resets indexer status to invalid
indexer:set-mode Sets index mode type
indexer:show-mode Shows Index Mode
indexer:status Shows status of Indexer

Many merchants cannot reindex from the command line, for several possible reasons:

  • They do not understand how to use the command line and command syntax
  • They prefer to manage their site from a graphical user interface
  • They do not have access to use the command line (may be blocked by developer or solution partner)

Merchants who have to contact a developer or Solution Partner to reindex the site may incur additional development cost.

Feature Description:

In the Admin Panel merchants can view Indexes and status through the System > Index Management menu. This page shows all indexes, along with the description, mode (save/schedule), status, and last updated timestamp for each index. Merchant users can select one, more than one, or all indexes using the selection grid.

A new action should be added named 'Reindex' to the existing action drop-down menu. The existing options are 'Update on Save' and 'Update by Schedule'. If the user selects 'Reindex' a button appears labeled 'Submit'. Next to the button is a status that shows the number of records shown and selected in the grid: 'x records found (x selected)'. When the user clicks 'Submit' the selected indexes are reindexed.

Acceptance Criteria:

  • User can select one, more than one, or all records from grid
  • After user clicks 'Submit' selected indexes are reindexed
  • Reindex action is identical to reindex initiated from the command line
  • Page is refreshed after 'Submit' click action to show current status of each index
  • Success or failure message is shown to user after clicking 'Submit'
  • Status of each index is displayed in the 'Status' column (existing behavior)
  • Merchant documentation for feature created
  • Developer documentation for CLI index commands updated to reference new feature in admin panel

Additional Information:

Screenshot showing how feature was possible from M1 Admin Panel:

m1 admin reindex

Screenshot from Magento 2 Admin Panel:

  • Shows existing Index Management Grid
  • Shows in-process state of Product Price Index (PROCESSING)
  • Shows summary of user-selected grid items: 10 records found (2 selected)
m2 admin index

mbrinton01 avatar Mar 07 '18 19:03 mbrinton01

This is a good suggestion, but It's a bad idea to allow this to run in a synchronous way. Mostly the webserver or php itself are setup to only allow to run a single request for a maximum number of seconds or minutes. So if you execute the reindexing through the webserver, and the reindexing takes too long, it will result in a timeout and certain reindex jobs might have stopped halfway in the process.

If this gets implemented, it should start a new php process which runs in a separate thread in the background. The downside is that you won't see the result of this, unless you refresh the page all the time to see if the reindexing is still in progress or has finished. It also then depends on how the php-cli.ini file is setup, we always set it up so there isn't a timeout, but I'm pretty sure some hosting companies will also have a certain timeout being defined over there.

We have a build a small module at our office which does this reindexing in an asynchronous way when triggered from the index management screen, but it currently isn't open source, I'll try to figure out if I can share some code from it.

hostep avatar Mar 10 '18 11:03 hostep

Excellent point. The reindex could easily exceed the server or php timeout for large sites. It will have to be done asynchronously.

mbrinton01 avatar Mar 22 '18 18:03 mbrinton01

This was implemented in https://github.com/magento/magento2/pull/25860 which landed in Magento version 2.4.0.

fredden avatar Feb 01 '22 21:02 fredden