Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SearchWeight.php
Go to the documentation of this file.
1 <?php
8 
17 {
21  public function __construct(
22  \Magento\Framework\Search\Request\Config $config
23  ) {
24  $this->config = $config;
25  }
26 
49  public function aroundSave(
50  \Magento\Catalog\Model\ResourceModel\Attribute $subject,
51  \Closure $proceed,
52  \Magento\Framework\Model\AbstractModel $attribute
53  ) {
54  $isNew = $attribute->isObjectNew();
55  $isWeightChanged = $attribute->dataHasChangedFor('search_weight');
56 
57  $result = $proceed($attribute);
58  if ($isNew || $isWeightChanged) {
59  $this->config->reset();
60  }
61 
62  return $result;
63  }
64 }
$config
Definition: fraud_order.php:17
aroundSave(\Magento\Catalog\Model\ResourceModel\Attribute $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $attribute)
__construct(\Magento\Framework\Search\Request\Config $config)