![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-inventory-indexer/Indexer/Stock/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\InventoryIndexer\Indexer\Stock; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\ObjectManagerInterface; use Magento\InventoryIndexer\Model\IndexerConfig; /** * Receiver of currently active reindex strategy for stock * * @api */ class StockReindexStrategy { /** * @var ObjectManagerInterface */ private $objectManager; /** * @var array */ private $strategies; /** * @var IndexerConfig */ private $indexerConfig; /** * @param ObjectManagerInterface $objectManager * @param IndexerConfig $indexerConfig * @param array $strategies */ public function __construct( ObjectManagerInterface $objectManager, IndexerConfig $indexerConfig, $strategies = [] ) { $this->objectManager = $objectManager; $this->strategies = $strategies; $this->indexerConfig = $indexerConfig; } /** * Reindex all stocks. * * @return void * @throws LocalizedException */ public function executeFull(): void { $strategy = $this->objectManager->get($this->getStrategy()); $strategy->executeFull(); } /** * Reindex given stock. * * @param int $stockId * @return void * @throws LocalizedException */ public function executeRow(int $stockId): void { $strategy = $this->objectManager->get($this->getStrategy()); $strategy->executeList([$stockId]); } /** * Reindex given stocks. * * @param array $stockIds * @return void * @throws LocalizedException */ public function executeList(array $stockIds): void { $strategy = $this->objectManager->get($this->getStrategy()); $strategy->executeList($stockIds); } /** * Retrieve reindex strategy. * * @return string * @throws LocalizedException */ private function getStrategy(): string { $enabledStrategy = $this->indexerConfig->getActiveIndexStrategy(); if (!isset($this->strategies[$enabledStrategy])) { throw new LocalizedException(__("Index Strategy not found, please check system settings.")); } return $this->strategies[$enabledStrategy]; } }