-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Plugins to invalidate StockItem indexes when Stock-to-Source assignments have been changed #68
Comments
Hi @maghamed, I found the following function in the Interface. But I see a performance problem because I can not specifies which data is invalid if is the indexer in the scheduled mode. For big merchant need a full reindex hours only because one Source is not assigned anymore. My current Implementation: <?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Inventory\Plugin;
use Magento\Framework\Indexer\IndexerInterfaceFactory;
use Magento\Inventory\Indexer\StockItemIndexerInterface;
use Magento\InventoryApi\Api\UnassignSourceFromStockInterface;
class UnassignSourceFromStock
{
/**
* @var \Magento\Framework\Indexer\IndexerInterface
*/
private $indexer;
/**
* @param IndexerInterfaceFactory $indexerFactory
*/
public function __construct(IndexerInterfaceFactory $indexerFactory)
{
/** @var $indexer */
$this->indexer = $indexerFactory->create();
$this->indexer->load(StockItemIndexerInterface::INDEXER_ID);
}
public function aroundExecute(
UnassignSourceFromStockInterface $subject,
\Closure $proceed,
int $sourceId
) {
if ($this->indexer->isScheduled()) {
$this->indexer->invalidate();
} else {
$this->indexer->reindexRow($sourceId);
}
}
} |
Results after the discussion :
|
Create Plugins to invalidate StockItem indexes when Stock-to-Source assignments have been changed.
For now, we don't mark index as invalid after some changes happened in Sources-to-Stocks assignment.
Precondition:
Source A: assigned to Stock 1
Source B: assigned to Stock 2
after that, we decided to assign:
Source B: assigned to Stock 1
after this operation, we need to invalidate whole
Stock 1
index, because all the StockItems forStock 1
should be re-calculated.It's a good architectural task because we need to invalidate not the whole indexes , but specific dimensions (Stocks) which were affected
The text was updated successfully, but these errors were encountered: