Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog
Pricing
Price
SpecialPrice.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Catalog\Pricing\Price
;
8
9
use
Magento\Catalog\Model\Product
;
10
use
Magento\Framework\Pricing\Adjustment\CalculatorInterface
;
11
use
Magento\Framework\Pricing\Price\AbstractPrice
;
12
use
Magento\Framework\Pricing\Price\BasePriceProviderInterface
;
13
use
Magento\Framework\Stdlib\DateTime\TimezoneInterface
;
14
18
class
SpecialPrice
extends
AbstractPrice
implements
SpecialPriceInterface
,
BasePriceProviderInterface
19
{
23
const
PRICE_CODE
=
'special_price'
;
24
28
protected
$localeDate
;
29
37
public
function
__construct
(
38
Product
$saleableItem,
39
$quantity
,
40
CalculatorInterface
$calculator
,
41
\
Magento
\Framework\Pricing\
PriceCurrencyInterface
$priceCurrency
,
42
TimezoneInterface
$localeDate
43
) {
44
parent::__construct($saleableItem,
$quantity
,
$calculator
,
$priceCurrency
);
45
$this->localeDate =
$localeDate
;
46
}
47
51
public
function
getValue
()
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
}
63
69
public
function
getSpecialPrice
()
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
}
77
83
public
function
getSpecialFromDate
()
84
{
85
return
$this->product->getSpecialFromDate();
86
}
87
93
public
function
getSpecialToDate
()
94
{
95
return
$this->product->getSpecialToDate();
96
}
97
101
public
function
isScopeDateInInterval
()
102
{
103
return
$this->localeDate->isScopeDateInInterval(
104
$this->product->getStore(),
105
$this->
getSpecialFromDate
(),
106
$this->
getSpecialToDate
()
107
);
108
}
109
113
public
function
isPercentageDiscount
()
114
{
115
return
false
;
116
}
117
}
value
$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
Magento\Catalog\Pricing\Price\SpecialPrice
Definition:
SpecialPrice.php:18
Magento\Catalog\Pricing\Price\SpecialPrice\isScopeDateInInterval
isScopeDateInInterval()
Definition:
SpecialPrice.php:101
Magento\Framework\Pricing\Price\AbstractPrice\$priceCurrency
$priceCurrency
Definition:
AbstractPrice.php:66
Magento\Catalog\Pricing\Price\SpecialPriceInterface
Definition:
SpecialPriceInterface.php:12
Magento\Catalog\Pricing\Price\SpecialPrice\$localeDate
$localeDate
Definition:
SpecialPrice.php:28
Magento\Catalog\Pricing\Price\SpecialPrice\isPercentageDiscount
isPercentageDiscount()
Definition:
SpecialPrice.php:113
Magento\Catalog\Pricing\Price\SpecialPrice\getSpecialPrice
getSpecialPrice()
Definition:
SpecialPrice.php:69
Magento\Framework\Stdlib\DateTime\TimezoneInterface
Definition:
TimezoneInterface.php:14
Magento\Framework\Pricing\Price\AbstractPrice
Definition:
AbstractPrice.php:21
Magento\Framework\Pricing\Price\AbstractPrice\$value
$value
Definition:
AbstractPrice.php:61
Magento\Framework\Pricing\PriceCurrencyInterface
Definition:
PriceCurrencyInterface.php:15
Magento\Catalog\Model\Product
Definition:
Product.php:42
Magento\Framework\Pricing\Adjustment\CalculatorInterface
Definition:
CalculatorInterface.php:17
Magento\Catalog\Pricing\Price\SpecialPrice\PRICE_CODE
const PRICE_CODE
Definition:
SpecialPrice.php:23
Magento\Framework\Pricing\Price\BasePriceProviderInterface
Definition:
BasePriceProviderInterface.php:15
Magento\Catalog\Model\Product
Definition:
ActionTest.php:6
Magento
Magento\Catalog\Pricing\Price\SpecialPrice\__construct
__construct(Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, TimezoneInterface $localeDate)
Definition:
SpecialPrice.php:37
Magento\Framework\Pricing\Price\AbstractPrice\$quantity
$quantity
Definition:
AbstractPrice.php:51
Magento\Catalog\Pricing\Price\SpecialPrice\getSpecialToDate
getSpecialToDate()
Definition:
SpecialPrice.php:93
Magento\Catalog\Pricing\Price\SpecialPrice\getSpecialFromDate
getSpecialFromDate()
Definition:
SpecialPrice.php:83
Magento\Catalog\Pricing\Price
Definition:
BasePrice.php:7
Magento\Catalog\Pricing\Price\SpecialPrice\getValue
getValue()
Definition:
SpecialPrice.php:51
Magento\Framework\Pricing\Price\AbstractPrice\$calculator
$calculator
Definition:
AbstractPrice.php:36