1717use Magento \CatalogImportExport \Model \Import \Product \StatusProcessor ;
1818use Magento \CatalogImportExport \Model \Import \Product \StockProcessor ;
1919use Magento \CatalogImportExport \Model \StockItemImporterInterface ;
20+ use Magento \CatalogImportExport \Model \StockItemProcessorInterface ;
2021use Magento \CatalogInventory \Api \Data \StockItemInterface ;
2122use Magento \Framework \App \Filesystem \DirectoryList ;
2223use Magento \Framework \App \ObjectManager ;
@@ -229,7 +230,6 @@ class Product extends AbstractEntity
229230 * @see LinkProcessor
230231 *
231232 * @see Magento_CatalogImportExport::etc/di.xml
232- *
233233 * @var array
234234 */
235235 protected $ _linkNameToId = [
@@ -620,9 +620,8 @@ class Product extends AbstractEntity
620620 /**
621621 * @var array
622622 * @deprecated 100.0.3
623- * @see nothing
624- * @since 100.0.3
625623 *
624+ * @since 100.0.3
626625 * @see we don't recommend this approach anymore
627626 */
628627 protected $ productUrlKeys = [];
@@ -762,6 +761,11 @@ class Product extends AbstractEntity
762761 */
763762 private $ linkProcessor ;
764763
764+ /**
765+ * @var StockItemProcessorInterface
766+ */
767+ private $ stockItemProcessor ;
768+
765769 /**
766770 * @param \Magento\Framework\Json\Helper\Data $jsonHelper
767771 * @param \Magento\ImportExport\Helper\Data $importExportData
@@ -811,6 +815,7 @@ class Product extends AbstractEntity
811815 * @param StockProcessor|null $stockProcessor
812816 * @param LinkProcessor|null $linkProcessor
813817 * @param File|null $fileDriver
818+ * @param StockItemProcessorInterface|null $stockItemProcessor
814819 * @throws LocalizedException
815820 * @throws \Magento\Framework\Exception\FileSystemException
816821 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -865,7 +870,8 @@ public function __construct(
865870 StatusProcessor $ statusProcessor = null ,
866871 StockProcessor $ stockProcessor = null ,
867872 LinkProcessor $ linkProcessor = null ,
868- ?File $ fileDriver = null
873+ ?File $ fileDriver = null ,
874+ ?StockItemProcessorInterface $ stockItemProcessor = null
869875 ) {
870876 $ this ->_eventManager = $ eventManager ;
871877 $ this ->stockRegistry = $ stockRegistry ;
@@ -929,6 +935,8 @@ public function __construct(
929935 $ this ->dateTimeFactory = $ dateTimeFactory ?? ObjectManager::getInstance ()->get (DateTimeFactory::class);
930936 $ this ->productRepository = $ productRepository ?? ObjectManager::getInstance ()
931937 ->get (ProductRepositoryInterface::class);
938+ $ this ->stockItemProcessor = $ stockItemProcessor ?? ObjectManager::getInstance ()
939+ ->get (StockItemProcessorInterface::class);
932940 }
933941
934942 /**
@@ -1292,6 +1300,7 @@ protected function _prepareRowForDb(array $rowData)
12921300 *
12931301 * @deprecated 101.1.0 use linkProcessor Directly
12941302 * @see linkProcessor
1303+ *
12951304 * @return $this
12961305 */
12971306 protected function _saveLinks ()
@@ -2388,6 +2397,7 @@ protected function _saveStockItem()
23882397 {
23892398 while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
23902399 $ stockData = [];
2400+ $ importedData = [];
23912401 $ productIdsToReindex = [];
23922402 $ stockChangedProductIds = [];
23932403 // Format bunch to stock data rows
@@ -2413,12 +2423,13 @@ protected function _saveStockItem()
24132423
24142424 if (!isset ($ stockData [$ sku ])) {
24152425 $ stockData [$ sku ] = $ row ;
2426+ $ importedData [$ sku ] = $ rowData ;
24162427 }
24172428 }
24182429
24192430 // Insert rows
24202431 if (!empty ($ stockData )) {
2421- $ this ->stockItemImporter -> import ($ stockData );
2432+ $ this ->stockItemProcessor -> process ($ stockData, $ importedData );
24222433 }
24232434
24242435 $ this ->reindexStockStatus ($ stockChangedProductIds );
@@ -2572,6 +2583,7 @@ public function getRowScope(array $rowData)
25722583 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
25732584 * @SuppressWarnings(PHPMD.NPathComplexity)
25742585 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
2586+ * @throws \Zend_Validate_Exception
25752587 */
25762588 public function validateRow (array $ rowData , $ rowNum )
25772589 {
0 commit comments