Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvalidatePriceIndexUponConfigChangeObserver.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 
19 {
23  private $priceIndexProcessor;
24 
28  public function __construct(Processor $priceIndexProcessor)
29  {
30  $this->priceIndexProcessor = $priceIndexProcessor;
31  }
32 
40  public function execute(Observer $observer)
41  {
42  $changedPaths = (array) $observer->getEvent()->getChangedPaths();
43 
44  if (\in_array(Configuration::XML_PATH_SHOW_OUT_OF_STOCK, $changedPaths, true)) {
45  $priceIndexer = $this->priceIndexProcessor->getIndexer();
46  $priceIndexer->invalidate();
47  }
48  }
49 }