Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PriceScope.php
Go to the documentation of this file.
1 <?php
7 
11 class PriceScope extends \Magento\Framework\App\Config\Value
12 {
16  protected $indexerRegistry;
17 
28  public function __construct(
29  \Magento\Framework\Model\Context $context,
30  \Magento\Framework\Registry $registry,
34  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
35  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
36  array $data = []
37  ) {
38  parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
39  $this->indexerRegistry = $indexerRegistry;
40  }
41 
47  public function afterSave()
48  {
49  $this->_getResource()->addCommitCallback([$this, 'processValue']);
50  return parent::afterSave();
51  }
52 
58  public function processValue()
59  {
60  if ($this->isValueChanged()) {
61  $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)
62  ->invalidate();
63  }
64  }
65 }
$config
Definition: fraud_order.php:17
$resource
Definition: bulk.php:12
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
Definition: PriceScope.php:28