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

Public Member Functions

 __construct (\Magento\Framework\Pricing\SaleableInterface $saleableItem, $quantity, \Magento\Framework\Pricing\Adjustment\CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, PriceResolverInterface $priceResolver, LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider=null)
 
 getValue ()
 
 getAmount ()
 
 getMaxRegularAmount ()
 
 getMinRegularAmount ()
 
- 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 = 'regular_price'
 
- Data Fields inherited from AbstractPrice
const PRICE_CODE = 'abstract_price'
 

Protected Member Functions

 doGetMaxRegularAmount ()
 
 doGetMinRegularAmount ()
 
 getUsedProducts ()
 

Protected Attributes

 $maxRegularAmount
 
 $minRegularAmount
 
 $values = []
 
 $priceResolver
 
- Protected Attributes inherited from AbstractPrice
 $amount
 
 $calculator
 
 $product
 
 $priceType
 
 $quantity
 
 $priceInfo
 
 $value
 
 $priceCurrency
 

Detailed Description

Class RegularPrice

Definition at line 16 of file ConfigurableRegularPrice.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Pricing\SaleableInterface  $saleableItem,
  $quantity,
\Magento\Framework\Pricing\Adjustment\CalculatorInterface  $calculator,
\Magento\Framework\Pricing\PriceCurrencyInterface  $priceCurrency,
PriceResolverInterface  $priceResolver,
LowestPriceOptionsProviderInterface  $lowestPriceOptionsProvider = null 
)
Parameters
\Magento\Framework\Pricing\SaleableInterface$saleableItem
float$quantity
\Magento\Framework\Pricing\Adjustment\CalculatorInterface$calculator
\Magento\Framework\Pricing\PriceCurrencyInterface$priceCurrency
PriceResolverInterface$priceResolver
LowestPriceOptionsProviderInterface$lowestPriceOptionsProvider

Definition at line 61 of file ConfigurableRegularPrice.php.

68  {
69  parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
70  $this->priceResolver = $priceResolver;
71  $this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider ?:
72  ObjectManager::getInstance()->get(LowestPriceOptionsProviderInterface::class);
73  }

Member Function Documentation

◆ doGetMaxRegularAmount()

doGetMaxRegularAmount ( )
protected

Get max regular amount

Returns
\Magento\Framework\Pricing\Amount\AmountInterface

Definition at line 111 of file ConfigurableRegularPrice.php.

112  {
113  $maxAmount = null;
114  foreach ($this->getUsedProducts() as $product) {
115  $childPriceAmount = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getAmount();
116  if (!$maxAmount || ($childPriceAmount->getValue() > $maxAmount->getValue())) {
117  $maxAmount = $childPriceAmount;
118  }
119  }
120  return $maxAmount;
121  }

◆ doGetMinRegularAmount()

doGetMinRegularAmount ( )
protected

Get min regular amount

Returns
\Magento\Framework\Pricing\Amount\AmountInterface

Definition at line 139 of file ConfigurableRegularPrice.php.

140  {
141  $minAmount = null;
142  foreach ($this->lowestPriceOptionsProvider->getProducts($this->product) as $product) {
143  $childPriceAmount = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getAmount();
144  if (!$minAmount || ($childPriceAmount->getValue() < $minAmount->getValue())) {
145  $minAmount = $childPriceAmount;
146  }
147  }
148  return $minAmount;
149  }

◆ getAmount()

getAmount ( )

{Get Price Amount object

Returns
AmountInterface
}

Implements PriceInterface.

Definition at line 90 of file ConfigurableRegularPrice.php.

◆ getMaxRegularAmount()

getMaxRegularAmount ( )

{Get max regular amount

Returns
\Magento\Framework\Pricing\Amount\AmountInterface
}

Implements ConfigurableRegularPriceInterface.

Definition at line 98 of file ConfigurableRegularPrice.php.

99  {
100  if (null === $this->maxRegularAmount) {
101  $this->maxRegularAmount = $this->doGetMaxRegularAmount() ?: false;
102  }
104  }

◆ getMinRegularAmount()

getMinRegularAmount ( )

{Get min regular amount

Returns
\Magento\Framework\Pricing\Amount\AmountInterface
}

Implements ConfigurableRegularPriceInterface.

Definition at line 126 of file ConfigurableRegularPrice.php.

127  {
128  if (null === $this->minRegularAmount) {
129  $this->minRegularAmount = $this->doGetMinRegularAmount() ?: parent::getAmount();
130  }
132  }

◆ getUsedProducts()

getUsedProducts ( )
protected

Get children simple products

Returns
Product[]

Definition at line 156 of file ConfigurableRegularPrice.php.

157  {
158  return $this->getConfigurableOptionsProvider()->getProducts($this->product);
159  }

◆ getValue()

getValue ( )

{Get price value

Returns
float
}

Implements PriceInterface.

Definition at line 78 of file ConfigurableRegularPrice.php.

79  {
80  if (!isset($this->values[$this->product->getId()])) {
81  $this->values[$this->product->getId()] = $this->priceResolver->resolvePrice($this->product);
82  }
83 
84  return $this->values[$this->product->getId()];
85  }

Field Documentation

◆ $maxRegularAmount

$maxRegularAmount
protected

Definition at line 26 of file ConfigurableRegularPrice.php.

◆ $minRegularAmount

$minRegularAmount
protected

Definition at line 31 of file ConfigurableRegularPrice.php.

◆ $priceResolver

$priceResolver
protected

Definition at line 41 of file ConfigurableRegularPrice.php.

◆ $values

$values = []
protected

Definition at line 36 of file ConfigurableRegularPrice.php.

◆ PRICE_CODE

const PRICE_CODE = 'regular_price'

Price type

Definition at line 21 of file ConfigurableRegularPrice.php.


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