![]() 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/Strategy/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\InventoryIndexer\Indexer\Stock\Strategy; use Magento\Framework\MessageQueue\PublisherInterface; use Magento\InventoryIndexer\Indexer\Stock\GetAllStockIds; /** * Reindex stocks asynchronously. */ class Async { /** * Queue topic name. */ private const TOPIC_STOCK_INDEX = "inventory.indexer.stock"; /** * @var PublisherInterface */ private $publisher; /** * @var GetAllStockIds */ private $getAllStockIds; /** * @param GetAllStockIds $getAllStockIds * @param PublisherInterface $publisher */ public function __construct( GetAllStockIds $getAllStockIds, PublisherInterface $publisher ) { $this->getAllStockIds = $getAllStockIds; $this->publisher = $publisher; } /** * Schedule full stock reindex. * * @return void */ public function executeFull(): void { $stockIds = $this->getAllStockIds->execute(); $this->executeList($stockIds); } /** * Schedule reindex of one item by id. * * @param int $stockId * @return void */ public function executeRow(int $stockId): void { $this->executeList([$stockId]); } /** * Schedule reindex of stocks list. * * @param array $stockIds * @return void */ public function executeList(array $stockIds): void { $stockIds = array_map('intval', $stockIds); $this->publisher->publish(self::TOPIC_STOCK_INDEX, $stockIds); } }