Stock Item reindex acts as "update on save" even when using "update on schedule"
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 357
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
Preconditions
- Magento 2.3.0
- Inventory indexer set to "Update on schedule"
Steps to reproduce
- Use import-export feature to import any MSI stock items
Expected result
- Stock items are saved
- Reindexing is handled by scheduled cron
Actual result
- Reindexing is handled immediately after import, then again by scheduled cron
Why this happens
The underlying impleentation for all of the import strategies (replace/append/delete) uses the following interface for handling the save operation, which has a plugin attached to it to ensure that a reindex takes place.
# vendor/magento/module-inventory-indexer/etc/di.xml
<type name="Magento\InventoryApi\Api\SourceItemsSaveInterface">
<plugin name="reindex_after_source_items_save" type="Magento\InventoryIndexer\Plugin\InventoryApi\ReindexAfterSourceItemsSavePlugin"/>
</type>
The plugin does not test the current indexing strategy (save/schedule) to decide if the reindex should happen immediately or be scheduled for later.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with vendor/magento/module-inventory-indexer/etc/di.xml and Magento\InventoryIndexer\Plugin\InventoryApi\ReindexAfterSourceItemsSavePlugin, then trace how the import strategies call SourceItemsSaveInterface. Done means imports using "Update on schedule" do not trigger an immediate reindex, while scheduled cron still handles reindexing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100