Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheFlush.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $flushCacheByProductIds;
23 
27  private $getProductIdsByStockIds;
28 
33  public function __construct(
34  FlushCacheByProductIds $flushCacheByProductIds,
35  GetProductIdsByStockIds $getProductIdsForCacheFlush
36  ) {
37  $this->flushCacheByProductIds = $flushCacheByProductIds;
38  $this->getProductIdsByStockIds = $getProductIdsForCacheFlush;
39  }
40 
51  public function aroundExecuteList(StockIndexer $subject, callable $proceed, array $stockIds)
52  {
53  $beforeReindexProductIds = $this->getProductIdsByStockIds->execute($stockIds);
54  $proceed($stockIds);
55  $afterReindexProductIds = $this->getProductIdsByStockIds->execute($stockIds);
56  $productIdsForCacheClean = array_diff($beforeReindexProductIds, $afterReindexProductIds);
57  if ($productIdsForCacheClean) {
58  $this->flushCacheByProductIds->execute($productIdsForCacheClean);
59  }
60  }
61 }
aroundExecuteList(StockIndexer $subject, callable $proceed, array $stockIds)
Definition: CacheFlush.php:51
__construct(FlushCacheByProductIds $flushCacheByProductIds, GetProductIdsByStockIds $getProductIdsForCacheFlush)
Definition: CacheFlush.php:33