File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed
app/code/Magento/CatalogImportExport Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 14
14
use Magento \CatalogImportExport \Model \Import \Product \MediaGalleryProcessor ;
15
15
use Magento \CatalogImportExport \Model \Import \Product \RowValidatorInterface as ValidatorInterface ;
16
16
use Magento \CatalogImportExport \Model \Import \Product \StatusProcessor ;
17
+ use Magento \CatalogImportExport \Model \Import \Product \StockProcessor ;
17
18
use Magento \CatalogImportExport \Model \StockItemImporterInterface ;
18
19
use Magento \CatalogInventory \Api \Data \StockItemInterface ;
19
- use Magento \CatalogInventory \Model \Indexer \Stock \Processor as StockProcessor ;
20
20
use Magento \Framework \App \Filesystem \DirectoryList ;
21
21
use Magento \Framework \App \ObjectManager ;
22
22
use Magento \Framework \Exception \LocalizedException ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \CatalogImportExport \Model \Import \Product ;
9
+
10
+ use Magento \Framework \Indexer \IndexerRegistry ;
11
+
12
+ /**
13
+ * Imported product stock manager
14
+ */
15
+ class StockProcessor
16
+ {
17
+ /**
18
+ * @var IndexerRegistry
19
+ */
20
+ private $ indexerRegistry ;
21
+ /**
22
+ * @var array
23
+ */
24
+ private $ indexers ;
25
+
26
+ /**
27
+ * Initializes dependencies.
28
+ *
29
+ * @param IndexerRegistry $indexerRegistry
30
+ * @param array $indexers
31
+ */
32
+ public function __construct (
33
+ IndexerRegistry $ indexerRegistry ,
34
+ array $ indexers = []
35
+ ) {
36
+ $ this ->indexerRegistry = $ indexerRegistry ;
37
+ $ this ->indexers = array_filter ($ indexers );
38
+ }
39
+
40
+ /**
41
+ * Reindex products by ids
42
+ *
43
+ * @param array $ids
44
+ * @return void
45
+ */
46
+ public function reindexList (array $ ids = []): void
47
+ {
48
+ if ($ ids ) {
49
+ foreach ($ this ->indexers as $ indexerName ) {
50
+ $ indexer = $ this ->indexerRegistry ->get ($ indexerName );
51
+ if (!$ indexer ->isScheduled ()) {
52
+ $ indexer ->reindexList ($ ids );
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
Original file line number Diff line number Diff line change 16
16
<plugin name =" invalidateProductCategoryIndexerOnImport" type =" Magento\CatalogImportExport\Model\Indexer\Product\Category\Plugin\Import" />
17
17
<plugin name =" invalidateCategoryProductIndexerOnImport" type =" Magento\CatalogImportExport\Model\Indexer\Category\Product\Plugin\Import" />
18
18
</type >
19
+ <type name =" Magento\CatalogImportExport\Model\Import\Product\StockProcessor" >
20
+ <arguments >
21
+ <argument name =" indexers" xsi : type =" array" >
22
+ <item name =" cataloginventory_stock" xsi : type =" const" >Magento\CatalogInventory\Model\Indexer\Stock\Processor::INDEXER_ID</item >
23
+ </argument >
24
+ </arguments >
25
+ </type >
19
26
<type name =" Magento\CatalogImportExport\Model\Import\Product\Validator" >
20
27
<arguments >
21
28
<argument name =" validators" xsi : type =" array" >
You can’t perform that action at this time.
0 commit comments