Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CatalogRulePrice.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\CatalogRule\Model\ResourceModel\RuleFactory;
19 
24 {
28  const PRICE_CODE = 'catalog_rule_price';
29 
33  protected $dateTime;
34 
38  protected $storeManager;
39 
43  protected $customerSession;
44 
50 
54  private $ruleResource;
55 
66  public function __construct(
67  Product $saleableItem,
68  $quantity,
74  RuleFactory $catalogRuleResourceFactory
75  ) {
76  parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
77  $this->dateTime = $dateTime;
78  $this->storeManager = $storeManager;
79  $this->customerSession = $customerSession;
80  $this->resourceRuleFactory = $catalogRuleResourceFactory;
81  }
82 
88  public function getValue()
89  {
90  if (null === $this->value) {
91  if ($this->product->hasData(self::PRICE_CODE)) {
92  $this->value = (float)$this->product->getData(self::PRICE_CODE) ?: false;
93  } else {
94  $this->value = $this->getRuleResource()
95  ->getRulePrice(
96  $this->dateTime->scopeDate($this->storeManager->getStore()->getId()),
97  $this->storeManager->getStore()->getWebsiteId(),
98  $this->customerSession->getCustomerGroupId(),
99  $this->product->getId()
100  );
101  $this->value = $this->value ? (float)$this->value : false;
102  }
103  if ($this->value) {
104  $this->value = $this->priceCurrency->convertAndRound($this->value);
105  }
106  }
107 
108  return $this->value;
109  }
110 
115  private function getRuleResource()
116  {
117  if (null === $this->ruleResource) {
118  $this->ruleResource = ObjectManager::getInstance()->get(Rule::class);
119  }
120 
121  return $this->ruleResource;
122  }
123 }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
__construct(Product $saleableItem, $quantity, Calculator $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, TimezoneInterface $dateTime, StoreManager $storeManager, Session $customerSession, RuleFactory $catalogRuleResourceFactory)