Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Category.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class Category
11 {
16 
20  public function __construct(
22  ) {
23  $this->productRuleProcessor = $productRuleProcessor;
24  }
25 
33  public function afterSave(
34  \Magento\Catalog\Model\Category $subject,
35  \Magento\Catalog\Model\Category $result
36  ) {
38  $productIds = $result->getChangedProductIds();
39  if (!empty($productIds) && !$this->productRuleProcessor->isIndexerScheduled()) {
40  $this->productRuleProcessor->reindexList($productIds);
41  }
42  return $result;
43  }
44 
52  public function afterDelete(
53  \Magento\Catalog\Model\Category $subject,
54  \Magento\Catalog\Model\Category $result
55  ) {
56  $this->productRuleProcessor->markIndexerAsInvalid();
57  return $result;
58  }
59 }
afterDelete(\Magento\Catalog\Model\Category $subject, \Magento\Catalog\Model\Category $result)
Definition: Category.php:52
__construct(ProductRuleProcessor $productRuleProcessor)
Definition: Category.php:20