16
16
use Magento \CatalogImportExport \Model \Import \Product \StatusProcessor ;
17
17
use Magento \CatalogImportExport \Model \Import \Product \StockProcessor ;
18
18
use Magento \CatalogImportExport \Model \StockItemImporterInterface ;
19
+ use Magento \CatalogImportExport \Model \StockItemProcessorInterface ;
19
20
use Magento \CatalogInventory \Api \Data \StockItemInterface ;
20
21
use Magento \Framework \App \Filesystem \DirectoryList ;
21
22
use Magento \Framework \App \ObjectManager ;
@@ -229,7 +230,6 @@ class Product extends AbstractEntity
229
230
* @deprecated 101.1.0 use DI for LinkProcessor class if you want to add additional types
230
231
*
231
232
* @see Magento_CatalogImportExport::etc/di.xml
232
- *
233
233
* @var array
234
234
*/
235
235
protected $ _linkNameToId = [
@@ -615,8 +615,8 @@ class Product extends AbstractEntity
615
615
/**
616
616
* @var array
617
617
* @deprecated 100.0.3
618
- * @since 100.0.3
619
618
*
619
+ * @since 100.0.3
620
620
* @see we don't recommend this approach anymore
621
621
*/
622
622
protected $ productUrlKeys = [];
@@ -756,6 +756,11 @@ class Product extends AbstractEntity
756
756
*/
757
757
private $ linkProcessor ;
758
758
759
+ /**
760
+ * @var StockItemProcessorInterface
761
+ */
762
+ private $ stockItemProcessor ;
763
+
759
764
/**
760
765
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
761
766
* @param \Magento\ImportExport\Helper\Data $importExportData
@@ -805,6 +810,7 @@ class Product extends AbstractEntity
805
810
* @param StockProcessor|null $stockProcessor
806
811
* @param LinkProcessor|null $linkProcessor
807
812
* @param File|null $fileDriver
813
+ * @param StockItemProcessorInterface|null $stockItemProcessor
808
814
* @throws LocalizedException
809
815
* @throws \Magento\Framework\Exception\FileSystemException
810
816
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -859,7 +865,8 @@ public function __construct(
859
865
StatusProcessor $ statusProcessor = null ,
860
866
StockProcessor $ stockProcessor = null ,
861
867
LinkProcessor $ linkProcessor = null ,
862
- ?File $ fileDriver = null
868
+ ?File $ fileDriver = null ,
869
+ ?StockItemProcessorInterface $ stockItemProcessor = null
863
870
) {
864
871
$ this ->_eventManager = $ eventManager ;
865
872
$ this ->stockRegistry = $ stockRegistry ;
@@ -923,6 +930,8 @@ public function __construct(
923
930
$ this ->dateTimeFactory = $ dateTimeFactory ?? ObjectManager::getInstance ()->get (DateTimeFactory::class);
924
931
$ this ->productRepository = $ productRepository ?? ObjectManager::getInstance ()
925
932
->get (ProductRepositoryInterface::class);
933
+ $ this ->stockItemProcessor = $ stockItemProcessor ?? ObjectManager::getInstance ()
934
+ ->get (StockItemProcessorInterface::class);
926
935
}
927
936
928
937
/**
@@ -1286,6 +1295,7 @@ protected function _prepareRowForDb(array $rowData)
1286
1295
*
1287
1296
* @deprecated 101.1.0 use linkProcessor Directly
1288
1297
* @see linkProcessor
1298
+ *
1289
1299
* @return $this
1290
1300
*/
1291
1301
protected function _saveLinks ()
@@ -2328,6 +2338,7 @@ protected function _saveStockItem()
2328
2338
{
2329
2339
while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
2330
2340
$ stockData = [];
2341
+ $ importedData = [];
2331
2342
$ productIdsToReindex = [];
2332
2343
$ stockChangedProductIds = [];
2333
2344
// Format bunch to stock data rows
@@ -2353,12 +2364,13 @@ protected function _saveStockItem()
2353
2364
2354
2365
if (!isset ($ stockData [$ sku ])) {
2355
2366
$ stockData [$ sku ] = $ row ;
2367
+ $ importedData [$ sku ] = $ rowData ;
2356
2368
}
2357
2369
}
2358
2370
2359
2371
// Insert rows
2360
2372
if (!empty ($ stockData )) {
2361
- $ this ->stockItemImporter -> import ($ stockData );
2373
+ $ this ->stockItemProcessor -> process ($ stockData, $ importedData );
2362
2374
}
2363
2375
2364
2376
$ this ->reindexStockStatus ($ stockChangedProductIds );
@@ -2512,6 +2524,7 @@ public function getRowScope(array $rowData)
2512
2524
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
2513
2525
* @SuppressWarnings(PHPMD.NPathComplexity)
2514
2526
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
2527
+ * @throws \Zend_Validate_Exception
2515
2528
*/
2516
2529
public function validateRow (array $ rowData , $ rowNum )
2517
2530
{
0 commit comments