RulePricesStorage.php 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogRule\Observer;
  7. class RulePricesStorage
  8. {
  9. /**
  10. * Store calculated catalog rules prices for products
  11. * Prices collected per website, customer group, date and product
  12. *
  13. * @var array
  14. */
  15. private $rulePrices = [];
  16. /**
  17. * @param string $id
  18. * @return false|float
  19. */
  20. public function getRulePrice($id)
  21. {
  22. return $this->rulePrices[$id] ?? false;
  23. }
  24. /**
  25. * @param string $id
  26. * @return bool
  27. */
  28. public function hasRulePrice($id)
  29. {
  30. return isset($this->rulePrices[$id]);
  31. }
  32. /**
  33. * @param string $id
  34. * @param float $price
  35. * @return void
  36. */
  37. public function setRulePrice($id, $price)
  38. {
  39. $this->rulePrices[$id] = $price;
  40. }
  41. }