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 ;
@@ -227,7 +228,7 @@ class Product extends AbstractEntity
227
228
* Links attribute name-to-link type ID.
228
229
*
229
230
* @deprecated 101.1.0 use DI for LinkProcessor class if you want to add additional types
230
- *
231
+ * @see It is possible to supply additional link types via DI
231
232
* @var array
232
233
*/
233
234
protected $ _linkNameToId = [
@@ -548,6 +549,7 @@ class Product extends AbstractEntity
548
549
/**
549
550
* @var \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory
550
551
* @deprecated 101.0.0 this variable isn't used anymore.
552
+ * @see avoid using this variable
551
553
*/
552
554
protected $ _stockResItemFac ;
553
555
@@ -613,6 +615,7 @@ class Product extends AbstractEntity
613
615
* @var array
614
616
* @deprecated 100.0.3
615
617
* @since 100.0.3
618
+ * @see avoid using this variable
616
619
*/
617
620
protected $ productUrlKeys = [];
618
621
@@ -751,6 +754,11 @@ class Product extends AbstractEntity
751
754
*/
752
755
private $ linkProcessor ;
753
756
757
+ /**
758
+ * @var StockItemProcessorInterface
759
+ */
760
+ private $ stockItemProcessor ;
761
+
754
762
/**
755
763
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
756
764
* @param \Magento\ImportExport\Helper\Data $importExportData
@@ -800,6 +808,7 @@ class Product extends AbstractEntity
800
808
* @param StockProcessor|null $stockProcessor
801
809
* @param LinkProcessor|null $linkProcessor
802
810
* @param File|null $fileDriver
811
+ * @param StockItemProcessorInterface|null $stockItemProcessor
803
812
* @throws LocalizedException
804
813
* @throws \Magento\Framework\Exception\FileSystemException
805
814
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -854,7 +863,8 @@ public function __construct(
854
863
StatusProcessor $ statusProcessor = null ,
855
864
StockProcessor $ stockProcessor = null ,
856
865
LinkProcessor $ linkProcessor = null ,
857
- ?File $ fileDriver = null
866
+ ?File $ fileDriver = null ,
867
+ ?StockItemProcessorInterface $ stockItemProcessor = null
858
868
) {
859
869
$ this ->_eventManager = $ eventManager ;
860
870
$ this ->stockRegistry = $ stockRegistry ;
@@ -918,6 +928,8 @@ public function __construct(
918
928
$ this ->dateTimeFactory = $ dateTimeFactory ?? ObjectManager::getInstance ()->get (DateTimeFactory::class);
919
929
$ this ->productRepository = $ productRepository ?? ObjectManager::getInstance ()
920
930
->get (ProductRepositoryInterface::class);
931
+ $ this ->stockItemProcessor = $ stockItemProcessor ?? ObjectManager::getInstance ()
932
+ ->get (StockItemProcessorInterface::class);
921
933
}
922
934
923
935
/**
@@ -1280,6 +1292,7 @@ protected function _prepareRowForDb(array $rowData)
1280
1292
* Must be called after ALL products saving done.
1281
1293
*
1282
1294
* @deprecated 101.1.0 use linkProcessor Directly
1295
+ * @see \Magento\CatalogImportExport\Model\Import\Product\linkProcessor::saveLinks
1283
1296
*
1284
1297
* @return $this
1285
1298
*/
@@ -1489,6 +1502,7 @@ private function getNewSkuFieldsForSelect()
1489
1502
* @return void
1490
1503
* @since 100.0.4
1491
1504
* @deprecated 100.2.3
1505
+ * @see avoid using this function
1492
1506
*/
1493
1507
protected function initMediaGalleryResources ()
1494
1508
{
@@ -2322,6 +2336,7 @@ protected function _saveStockItem()
2322
2336
{
2323
2337
while ($ bunch = $ this ->_dataSourceModel ->getNextBunch ()) {
2324
2338
$ stockData = [];
2339
+ $ importedData = [];
2325
2340
$ productIdsToReindex = [];
2326
2341
$ stockChangedProductIds = [];
2327
2342
// Format bunch to stock data rows
@@ -2347,12 +2362,13 @@ protected function _saveStockItem()
2347
2362
2348
2363
if (!isset ($ stockData [$ sku ])) {
2349
2364
$ stockData [$ sku ] = $ row ;
2365
+ $ importedData [$ sku ] = $ rowData ;
2350
2366
}
2351
2367
}
2352
2368
2353
2369
// Insert rows
2354
2370
if (!empty ($ stockData )) {
2355
- $ this ->stockItemImporter -> import ($ stockData );
2371
+ $ this ->stockItemProcessor -> process ($ stockData, $ importedData );
2356
2372
}
2357
2373
2358
2374
$ this ->reindexStockStatus ($ stockChangedProductIds );
0 commit comments