Skip to content

Commit fb77677

Browse files
committed
BUG#AC-1705
1 parent b65c2ad commit fb77677

File tree

1 file changed

+14
-4
lines changed
  • app/code/Magento/Catalog/Model/Indexer/Product/Price/Action

1 file changed

+14
-4
lines changed

app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Rows.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product\Price\Action;
77

8-
use Magento\Directory\Model\CurrencyFactory;
98
use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory;
109
use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
10+
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Model\Product\Type;
1212
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice;
1313
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory;
1414
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice;
15+
use Magento\Directory\Model\CurrencyFactory;
1516
use Magento\Framework\App\Config\ScopeConfigInterface;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Indexer\CacheContext;
1619
use Magento\Framework\Stdlib\DateTime;
1720
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1821
use Magento\Store\Model\StoreManagerInterface;
@@ -34,6 +37,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction
3437
*/
3538
private $batchSize;
3639

40+
/**
41+
* @var CacheContext
42+
*/
43+
private CacheContext $cacheContext;
44+
3745
/**
3846
* @param ScopeConfigInterface $config
3947
* @param StoreManagerInterface $storeManager
@@ -63,7 +71,8 @@ public function __construct(
6371
TierPrice $tierPriceIndexResource = null,
6472
DimensionCollectionFactory $dimensionCollectionFactory = null,
6573
TableMaintainer $tableMaintainer = null,
66-
?int $batchSize = null
74+
?int $batchSize = null,
75+
CacheContext $cacheContext = null
6776
) {
6877
parent::__construct(
6978
$config,
@@ -79,6 +88,7 @@ public function __construct(
7988
$tableMaintainer
8089
);
8190
$this->batchSize = $batchSize ?? self::BATCH_SIZE;
91+
$this->cacheContext = $cacheContext ?? ObjectManager::getInstance()->get(CacheContext::class);
8292
}
8393

8494
/**
@@ -101,7 +111,7 @@ public function execute($ids)
101111
$currentBatch[] = $id;
102112
if (++$i === $this->batchSize) {
103113
try {
104-
$this->_reindexRows($currentBatch);
114+
$this->cacheContext->registerEntities(Product::CACHE_TAG, $this->_reindexRows($currentBatch));
105115
} catch (\Exception $e) {
106116
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
107117
}
@@ -112,7 +122,7 @@ public function execute($ids)
112122

113123
if (!empty($currentBatch)) {
114124
try {
115-
$this->_reindexRows($currentBatch);
125+
$this->cacheContext->registerEntities(Product::CACHE_TAG, $this->_reindexRows($currentBatch));
116126
} catch (\Exception $e) {
117127
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
118128
}

0 commit comments

Comments
 (0)