Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
SpecialPrice Class Reference
Inheritance diagram for SpecialPrice:
AbstractPrice SpecialPriceInterface BasePriceProviderInterface PriceInterface SpecialPrice

Public Member Functions

 __construct (Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, TimezoneInterface $localeDate)
 
 getValue ()
 
 getSpecialPrice ()
 
 getSpecialFromDate ()
 
 getSpecialToDate ()
 
 isScopeDateInInterval ()
 
 isPercentageDiscount ()
 
- Public Member Functions inherited from AbstractPrice
 __construct (SaleableInterface $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency)
 
 getValue ()
 
 getAmount ()
 
 getCustomAmount ($amount=null, $exclude=null, $context=[])
 
 getPriceCode ()
 
 getProduct ()
 
 getQuantity ()
 

Data Fields

const PRICE_CODE = 'special_price'
 
- Data Fields inherited from AbstractPrice
const PRICE_CODE = 'abstract_price'
 

Protected Attributes

 $localeDate
 
- Protected Attributes inherited from AbstractPrice
 $amount
 
 $calculator
 
 $product
 
 $priceType
 
 $quantity
 
 $priceInfo
 
 $value
 
 $priceCurrency
 

Detailed Description

Special price model

Definition at line 18 of file SpecialPrice.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Product  $saleableItem,
  $quantity,
CalculatorInterface  $calculator,
\Magento\Framework\Pricing\PriceCurrencyInterface  $priceCurrency,
TimezoneInterface  $localeDate 
)
Parameters
Product$saleableItem
float$quantity
CalculatorInterface$calculator
\Magento\Framework\Pricing\PriceCurrencyInterface$priceCurrency
TimezoneInterface$localeDate

Definition at line 37 of file SpecialPrice.php.

Member Function Documentation

◆ getSpecialFromDate()

getSpecialFromDate ( )

Returns starting date of the special price

Returns
mixed

Implements SpecialPriceInterface.

Definition at line 83 of file SpecialPrice.php.

84  {
85  return $this->product->getSpecialFromDate();
86  }

◆ getSpecialPrice()

getSpecialPrice ( )

Returns special price

Returns
float

Implements SpecialPriceInterface.

Definition at line 69 of file SpecialPrice.php.

70  {
71  $specialPrice = $this->product->getSpecialPrice();
72  if ($specialPrice !== null && $specialPrice !== false && !$this->isPercentageDiscount()) {
73  $specialPrice = $this->priceCurrency->convertAndRound($specialPrice);
74  }
75  return $specialPrice;
76  }

◆ getSpecialToDate()

getSpecialToDate ( )

Returns end date of the special price

Returns
mixed

Implements SpecialPriceInterface.

Definition at line 93 of file SpecialPrice.php.

94  {
95  return $this->product->getSpecialToDate();
96  }

◆ getValue()

getValue ( )
Returns
bool|float

Implements PriceInterface.

Definition at line 51 of file SpecialPrice.php.

52  {
53  if (null === $this->value) {
54  $this->value = false;
55  $specialPrice = $this->getSpecialPrice();
56  if ($specialPrice !== null && $specialPrice !== false && $this->isScopeDateInInterval()) {
57  $this->value = (float) $specialPrice;
58  }
59  }
60 
61  return $this->value;
62  }
$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

◆ isPercentageDiscount()

isPercentageDiscount ( )
Returns
bool

Implements SpecialPriceInterface.

Definition at line 113 of file SpecialPrice.php.

114  {
115  return false;
116  }

◆ isScopeDateInInterval()

isScopeDateInInterval ( )
Returns
bool

Implements SpecialPriceInterface.

Definition at line 101 of file SpecialPrice.php.

102  {
103  return $this->localeDate->isScopeDateInInterval(
104  $this->product->getStore(),
105  $this->getSpecialFromDate(),
106  $this->getSpecialToDate()
107  );
108  }

Field Documentation

◆ $localeDate

$localeDate
protected

Definition at line 28 of file SpecialPrice.php.

◆ PRICE_CODE

const PRICE_CODE = 'special_price'

Price type special

Definition at line 23 of file SpecialPrice.php.


The documentation for this class was generated from the following file: