diff --git a/vendor/magento/module-catalog-import-export/Model/Import/Product.php b/vendor/magento/module-catalog-import-export/Model/Import/Product.php index d0c93658fc28..47646eea4ae2 100644 --- a/vendor/magento/module-catalog-import-export/Model/Import/Product.php +++ b/vendor/magento/module-catalog-import-export/Model/Import/Product.php @@ -16,6 +16,7 @@ use Magento\CatalogImportExport\Model\Import\Product\StatusProcessor; use Magento\CatalogImportExport\Model\Import\Product\StockProcessor; use Magento\CatalogImportExport\Model\StockItemImporterInterface; +use Magento\CatalogImportExport\Model\StockItemProcessorInterface; use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\ObjectManager; @@ -227,7 +228,6 @@ class Product extends AbstractEntity * Links attribute name-to-link type ID. * * @deprecated 101.1.0 use DI for LinkProcessor class if you want to add additional types - * * @var array */ protected $_linkNameToId = [ @@ -767,6 +767,11 @@ class Product extends AbstractEntity */ private $linkProcessor; + /** + * @var StockItemProcessorInterface + */ + private $stockItemProcessor; + /** * @var File */ @@ -821,6 +826,7 @@ class Product extends AbstractEntity * @param StockProcessor|null $stockProcessor * @param LinkProcessor|null $linkProcessor * @param File|null $fileDriver + * @param StockItemProcessorInterface|null $stockItemProcessor * @throws LocalizedException * @throws \Magento\Framework\Exception\FileSystemException * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -874,7 +880,8 @@ public function __construct( StatusProcessor $statusProcessor = null, StockProcessor $stockProcessor = null, LinkProcessor $linkProcessor = null, - ?File $fileDriver = null + ?File $fileDriver = null, + ?StockItemProcessorInterface $stockItemProcessor = null ) { $this->_eventManager = $eventManager; $this->stockRegistry = $stockRegistry; @@ -938,6 +945,8 @@ public function __construct( $this->dateTimeFactory = $dateTimeFactory ?? ObjectManager::getInstance()->get(DateTimeFactory::class); $this->productRepository = $productRepository ?? ObjectManager::getInstance() ->get(ProductRepositoryInterface::class); + $this->stockItemProcessor = $stockItemProcessor ?? ObjectManager::getInstance() + ->get(StockItemProcessorInterface::class); $this->fileDriver = $fileDriver ?: ObjectManager::getInstance()->get(File::class); } @@ -2354,6 +2363,7 @@ protected function _saveStockItem() { while ($bunch = $this->_dataSourceModel->getNextBunch()) { $stockData = []; + $importedData = []; $productIdsToReindex = []; $stockChangedProductIds = []; // Format bunch to stock data rows @@ -2379,12 +2389,13 @@ protected function _saveStockItem() if (!isset($stockData[$sku])) { $stockData[$sku] = $row; + $importedData[$sku] = $rowData; } } // Insert rows if (!empty($stockData)) { - $this->stockItemImporter->import($stockData); + $this->stockItemProcessor->process($stockData, $importedData); } $this->reindexStockStatus($stockChangedProductIds); diff --git a/vendor/magento/module-catalog-import-export/Model/StockItemProcessor.php b/vendor/magento/module-catalog-import-export/Model/StockItemProcessor.php new file mode 100644 index 000000000000..c1923b0d52ae --- /dev/null +++ b/vendor/magento/module-catalog-import-export/Model/StockItemProcessor.php @@ -0,0 +1,33 @@ +stockItemImporter = $stockItemImporter; + } + + /** + * @inheritdoc + */ + public function process(array $stockData, array $importedData): void + { + $this->stockItemImporter->import($stockData); + } +} diff --git a/vendor/magento/module-catalog-import-export/Model/StockItemProcessorInterface.php b/vendor/magento/module-catalog-import-export/Model/StockItemProcessorInterface.php new file mode 100644 index 000000000000..870bddde0116 --- /dev/null +++ b/vendor/magento/module-catalog-import-export/Model/StockItemProcessorInterface.php @@ -0,0 +1,27 @@ + +