Skip to content

Commit c2cb194

Browse files
committed
ACP2E-1524: Page Cache is not cleared for the parent product on the child product save
1 parent 9b7759e commit c2cb194

File tree

1 file changed

+10
-24
lines changed
  • app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel

1 file changed

+10
-24
lines changed

app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel/Product.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use Magento\Catalog\Api\Data\ProductAttributeInterface;
1212
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
13-
use Magento\Catalog\Model\Indexer\Product\Category\Action\Rows;
1413
use Magento\Catalog\Model\Indexer\Product\Price\Processor;
1514
use Magento\Catalog\Model\Product as ProductModel;
1615
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
@@ -21,12 +20,9 @@
2120
use Magento\Framework\App\ObjectManager;
2221
use Magento\Framework\DataObject;
2322
use Magento\Framework\Indexer\ActionInterface;
24-
use Magento\Framework\Indexer\IndexerRegistry;
2523

2624
/**
2725
* Plugin product resource model
28-
*
29-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3026
*/
3127
class Product
3228
{
@@ -56,14 +52,9 @@ class Product
5652
private $filterBuilder;
5753

5854
/**
59-
* @var IndexerRegistry
60-
*/
61-
private $indexerRegistry;
62-
63-
/**
64-
* @var Rows
55+
* @var Processor
6556
*/
66-
private $rowsAction;
57+
private $priceIndexProcessor;
6758

6859
/**
6960
* Initialize Product dependencies.
@@ -73,17 +64,15 @@ class Product
7364
* @param ProductAttributeRepositoryInterface|null $productAttributeRepository
7465
* @param SearchCriteriaBuilder|null $searchCriteriaBuilder
7566
* @param FilterBuilder|null $filterBuilder
76-
* @param IndexerRegistry|null $indexerRegistry
77-
* @param Rows|null $rowsAction
67+
* @param Processor|null $priceIndexProcessor
7868
*/
7969
public function __construct(
8070
Configurable $configurable,
8171
ActionInterface $productIndexer,
8272
ProductAttributeRepositoryInterface $productAttributeRepository = null,
8373
?SearchCriteriaBuilder $searchCriteriaBuilder = null,
8474
?FilterBuilder $filterBuilder = null,
85-
?IndexerRegistry $indexerRegistry = null,
86-
?Rows $rowsAction = null
75+
?Processor $priceIndexProcessor = null
8776
) {
8877
$this->configurable = $configurable;
8978
$this->productIndexer = $productIndexer;
@@ -93,10 +82,8 @@ public function __construct(
9382
->get(SearchCriteriaBuilder::class);
9483
$this->filterBuilder = $filterBuilder ?: ObjectManager::getInstance()
9584
->get(FilterBuilder::class);
96-
$this->indexerRegistry = $indexerRegistry ?: ObjectManager::getInstance()
97-
->get(IndexerRegistry::class);
98-
$this->rowsAction = $rowsAction ?: ObjectManager::getInstance()
99-
->get(Rows::class);
85+
$this->priceIndexProcessor = $priceIndexProcessor ?: ObjectManager::getInstance()
86+
->get(Processor::class);
10087
}
10188

10289
/**
@@ -134,11 +121,10 @@ public function afterSave(
134121
ProductResource $result,
135122
DataObject $object
136123
): ProductResource {
137-
$productId = $object->getId();
138-
$priceIndexer = $this->indexerRegistry->get(Processor::INDEXER_ID);
139-
if ($priceIndexer->isScheduled()
140-
&& count($this->configurable->getParentIdsByChild($productId)) > 0) {
141-
$this->rowsAction->execute([$productId]);
124+
$configurableProductIds = $this->configurable->getParentIdsByChild($object->getId());
125+
if (count($configurableProductIds) > 0) {
126+
$priceIndexer = $this->priceIndexProcessor->getIndexer();
127+
$priceIndexer->reindexList($configurableProductIds);
142128
}
143129

144130
return $result;

0 commit comments

Comments
 (0)