66
77namespace Magento \Catalog \Model \Indexer \Product \Price ;
88
9+ use Magento \Catalog \Model \Product ;
910use Magento \Catalog \Model \Product \Type ;
1011use Magento \Catalog \Model \ResourceModel \Product \Indexer \Price \DefaultPrice ;
1112use Magento \Catalog \Model \ResourceModel \Product \Indexer \Price \Factory ;
2021use Magento \Framework \Exception \InputException ;
2122use Magento \Framework \Exception \LocalizedException ;
2223use Magento \Framework \Exception \NoSuchEntityException ;
24+ use Magento \Framework \Indexer \CacheContext ;
2325use Magento \Framework \Indexer \DimensionalIndexerInterface ;
2426use Magento \Framework \Search \Request \Dimension ;
2527use Magento \Framework \Stdlib \DateTime ;
@@ -61,8 +63,6 @@ abstract class AbstractAction
6163 protected $ _storeManager ;
6264
6365 /**
64- * Currency factory
65- *
6666 * @var CurrencyFactory
6767 */
6868 protected $ _currencyFactory ;
@@ -83,8 +83,6 @@ abstract class AbstractAction
8383 protected $ _catalogProductType ;
8484
8585 /**
86- * Indexer price factory
87- *
8886 * @var Factory
8987 */
9088 protected $ _indexerPriceFactory ;
@@ -109,6 +107,11 @@ abstract class AbstractAction
109107 */
110108 private $ tableMaintainer ;
111109
110+ /**
111+ * @var CacheContext
112+ */
113+ private $ cacheContext ;
114+
112115 /**
113116 * @param ScopeConfigInterface $config
114117 * @param StoreManagerInterface $storeManager
@@ -121,6 +124,7 @@ abstract class AbstractAction
121124 * @param TierPrice|null $tierPriceIndexResource
122125 * @param DimensionCollectionFactory|null $dimensionCollectionFactory
123126 * @param TableMaintainer|null $tableMaintainer
127+ * @param CacheContext|null $cacheContext
124128 * @SuppressWarnings(PHPMD.NPathComplexity)
125129 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
126130 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -136,7 +140,8 @@ public function __construct(
136140 DefaultPrice $ defaultIndexerResource ,
137141 TierPrice $ tierPriceIndexResource = null ,
138142 DimensionCollectionFactory $ dimensionCollectionFactory = null ,
139- TableMaintainer $ tableMaintainer = null
143+ TableMaintainer $ tableMaintainer = null ,
144+ CacheContext $ cacheContext = null
140145 ) {
141146 $ this ->_config = $ config ;
142147 $ this ->_storeManager = $ storeManager ;
@@ -156,6 +161,7 @@ public function __construct(
156161 $ this ->tableMaintainer = $ tableMaintainer ?? ObjectManager::getInstance ()->get (
157162 TableMaintainer::class
158163 );
164+ $ this ->cacheContext = $ cacheContext ?? ObjectManager::getInstance ()->get (CacheContext::class);
159165 }
160166
161167 /**
@@ -391,6 +397,7 @@ protected function _reindexRows($changedIds = [])
391397
392398 if ($ changedIds ) {
393399 $ this ->deleteIndexData ($ changedIds );
400+ $ this ->cacheContext ->registerEntities (Product::CACHE_TAG , $ changedIds );
394401 }
395402
396403 $ typeIndexers = $ this ->getTypeIndexers ();
0 commit comments