MsrpPrice.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Msrp\Pricing\Price;
  7. use Magento\Catalog\Model\Product;
  8. use Magento\Catalog\Pricing\Price\FinalPrice;
  9. use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
  10. /**
  11. * MSRP price model
  12. */
  13. class MsrpPrice extends FinalPrice implements MsrpPriceInterface
  14. {
  15. /**
  16. * Price type MSRP
  17. */
  18. const PRICE_CODE = 'msrp_price';
  19. /**
  20. * @var \Magento\Msrp\Helper\Data
  21. */
  22. protected $msrpData;
  23. /**
  24. * @var \Magento\Msrp\Model\Config
  25. */
  26. protected $config;
  27. /**
  28. * @param Product $saleableItem
  29. * @param float $quantity
  30. * @param CalculatorInterface $calculator
  31. * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
  32. * @param \Magento\Msrp\Helper\Data $msrpData
  33. * @param \Magento\Msrp\Model\Config $config
  34. */
  35. public function __construct(
  36. Product $saleableItem,
  37. $quantity,
  38. CalculatorInterface $calculator,
  39. \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
  40. \Magento\Msrp\Helper\Data $msrpData,
  41. \Magento\Msrp\Model\Config $config
  42. ) {
  43. parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
  44. $this->msrpData = $msrpData;
  45. $this->config = $config;
  46. }
  47. /**
  48. * Returns whether the MSRP should be shown on gesture
  49. *
  50. * @return bool
  51. */
  52. public function isShowPriceOnGesture()
  53. {
  54. return $this->msrpData->isShowPriceOnGesture($this->product);
  55. }
  56. /**
  57. * Get Msrp message for price
  58. *
  59. * @return string
  60. */
  61. public function getMsrpPriceMessage()
  62. {
  63. return $this->msrpData->getMsrpPriceMessage($this->product);
  64. }
  65. /**
  66. * Check if Minimum Advertised Price is enabled
  67. *
  68. * @return bool
  69. */
  70. public function isMsrpEnabled()
  71. {
  72. return $this->config->isEnabled();
  73. }
  74. /**
  75. * Check if can apply Minimum Advertise price to product
  76. *
  77. * @param Product $product
  78. * @return bool
  79. */
  80. public function canApplyMsrp(Product $product)
  81. {
  82. return $this->msrpData->canApplyMsrp($product);
  83. }
  84. /**
  85. * @param Product $product
  86. * @return bool|float
  87. */
  88. public function isMinimalPriceLessMsrp(Product $product)
  89. {
  90. return $this->msrpData->isMinimalPriceLessMsrp($product);
  91. }
  92. }