Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PriceModifier.php
Go to the documentation of this file.
1 <?php
9 
12 use Magento\CatalogRule\Model\RuleFactory;
13 
15 {
19  protected $ruleFactory;
20 
24  public function __construct(RuleFactory $ruleFactory)
25  {
26  $this->ruleFactory = $ruleFactory;
27  }
28 
36  public function modifyPrice($price, Product $product)
37  {
38  if ($price !== null) {
39  $resultPrice = $this->ruleFactory->create()->calcProductPriceRule($product, $price);
40  if ($resultPrice !== null) {
41  $price = $resultPrice;
42  }
43  }
44  return $price;
45  }
46 }
$price