63 private $customerGroupRetriever;
81 CustomerGroupRetrieverInterface $customerGroupRetriever =
null 87 $this->customerGroupRetriever = $customerGroupRetriever
89 if ($saleableItem->hasCustomerGroupId()) {
90 $this->customerGroup = (int) $saleableItem->getCustomerGroupId();
92 $this->customerGroup = (int) $this->customerGroupRetriever->getCustomerGroupId();
103 if (
null === $this->
value) {
104 $prices = $this->getStoredTierPrices();
106 $this->
value = $prevPrice = $tierPrice =
false;
107 $priceGroup = $this->groupManagement->getAllCustomersGroup()->getId();
113 if (
false === $prevPrice || $this->
isFirstPriceBetter($price[
'website_price'], $prevPrice)) {
114 $tierPrice = $prevPrice =
$price[
'website_price'];
115 $prevQty =
$price[
'price_qty'];
116 $priceGroup =
$price[
'cust_group'];
117 $this->
value = (float)$tierPrice;
135 return $firstPrice < $secondPrice;
151 if (
null === $this->priceList) {
156 function (&$priceData) {
158 $priceData[
'price_qty'] = $priceData[
'price_qty'] * 1;
173 $allCustomersGroupId = $this->groupManagement->getAllCustomersGroup()->getId();
180 if (isset(
$price[
'price_qty']) &&
$price[
'price_qty'] == 1) {
185 if (
$price[
'cust_group'] != $this->customerGroup &&
186 $price[
'cust_group'] != $allCustomersGroupId) {
191 if (isset($qtyCache[
$price[
'price_qty']])) {
192 $priceQty = $qtyCache[
$price[
'price_qty']];
195 $qtyCache[
$price[
'price_qty']] = $priceKey;
200 $qtyCache[
$price[
'price_qty']] = $priceKey;
209 protected function getBasePrice()
225 $productPriceAmount = $this->priceInfo->getPrice(
230 100 - ((100 / $productPriceAmount->getValue()) *
$amount->getValue())
240 return $this->calculator->getAmount(
$price, $this->product);
253 $custGroupAllId = (int)$this->groupManagement->getAllCustomersGroup()->getId();
256 if ((
int)$currentTierPrice[
'cust_group'] !== $this->customerGroup
257 && (
int)$currentTierPrice[
'cust_group'] !== $custGroupAllId
262 if ($this->quantity < $currentTierPrice[
'price_qty']) {
266 if ($currentTierPrice[
'price_qty'] < $prevQty) {
270 if ($currentTierPrice[
'price_qty'] == $prevQty
271 && $prevPriceGroup !== $custGroupAllId
272 && $currentTierPrice[
'cust_group'] === $custGroupAllId
285 protected function getStoredTierPrices()
287 if (
null === $this->rawPriceList) {
288 $this->rawPriceList = $this->product->getData(self::PRICE_CODE);
289 if (
null === $this->rawPriceList || !is_array($this->rawPriceList)) {
291 $attribute = $this->product->getResource()->getAttribute(self::PRICE_CODE);
293 $attribute->getBackend()->afterLoad($this->product);
294 $this->rawPriceList = $this->product->getData(self::PRICE_CODE);
297 if (
null === $this->rawPriceList || !is_array($this->rawPriceList)) {
298 $this->rawPriceList = [];
301 foreach ($this->rawPriceList as
$index => $rawPrice) {
302 if (isset($rawPrice[
'price'])) {
303 $this->rawPriceList[
$index][
'price'] =
304 $this->priceCurrency->convertAndRound($rawPrice[
'price']);
306 if (isset($rawPrice[
'website_price'])) {
307 $this->rawPriceList[
$index][
'website_price'] =
308 $this->priceCurrency->convertAndRound($rawPrice[
'website_price']);
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
filterTierPrices(array $priceList)
canApplyTierPrice(array $currentTierPrice, $prevPriceGroup, $prevQty)
getSavePercent(AmountInterface $amount)
__construct(Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, Session $customerSession, GroupManagementInterface $groupManagement, CustomerGroupRetrieverInterface $customerGroupRetriever=null)
isFirstPriceBetter($firstPrice, $secondPrice)
const PRODUCT_QUANTITY_DEFAULT