Skip to content

Commit 6b4383b

Browse files
committed
minor changes
1 parent 30901be commit 6b4383b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,31 @@ function () use ($productId, $context) {
134134

135135
$productPrice = $this->tiers->getProductRegularPrice($productId) ?? 0.0;
136136
$tierPrices = $this->tiers->getProductTierPrices($productId) ?? [];
137-
return $this->formatAndFilterTierPrices($tierPrices, $productPrice, $currencyCode);
137+
return $this->formatAndFilterTierPrices($productId, $productPrice, $tierPrices, $currencyCode);
138138
}
139139
);
140140
}
141141

142142
/**
143143
* Format and filter tier prices for output
144144
*
145-
* @param ProductTierPriceInterface[] $tierPrices
145+
* @param int $productId
146146
* @param float $productPrice
147+
* @param ProductTierPriceInterface[] $tierPrices
147148
* @param string $currencyCode
148149
* @return array
149150
*/
150151
private function formatAndFilterTierPrices(
151-
array $tierPrices,
152+
int $productId,
152153
float $productPrice,
154+
array $tierPrices,
153155
string $currencyCode
154156
): array {
155157

156158
foreach ($tierPrices as $key => $tierPrice) {
157159
$tierPrice->setValue($this->priceCurrency->convertAndRound($tierPrice->getValue()));
158160
$this->formatTierPrices($productPrice, $currencyCode, $tierPrice);
159-
$this->filterTierPrices($tierPrices, $key, $tierPrice);
161+
$this->filterTierPrices($productId, $tierPrices, $key, $tierPrice);
160162
}
161163
return $this->formatAndFilterTierPrices;
162164
}
@@ -190,26 +192,28 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
190192
/**
191193
* Filter the lowest price for each quantity
192194
*
195+
* @param int $productId
193196
* @param array $tierPrices
194197
* @param int $key
195198
* @param ProductTierPriceInterface $tierPriceItem
196199
*/
197200
private function filterTierPrices(
201+
int $productId,
198202
array $tierPrices,
199203
int $key,
200204
ProductTierPriceInterface $tierPriceItem
201205
) {
202206
$qty = $tierPriceItem->getQty();
203-
if (isset($this->tierPricesQty[$qty])) {
204-
$priceQty = $this->tierPricesQty[$qty];
207+
if (isset($this->tierPricesQty[$productId][$qty])) {
208+
$priceQty = $this->tierPricesQty[$productId][$qty];
205209
if ((float)$tierPriceItem->getValue() < (float)$tierPrices[$priceQty]->getValue()) {
206210
unset($this->formatAndFilterTierPrices[$priceQty]);
207-
$this->tierPricesQty[$priceQty] = $key;
211+
$this->tierPricesQty[$productId][$priceQty] = $key;
208212
} else {
209213
unset($this->formatAndFilterTierPrices[$key]);
210214
}
211215
} else {
212-
$this->tierPricesQty[$qty] = $key;
216+
$this->tierPricesQty[$productId][$qty] = $key;
213217
}
214218
}
215219
}

0 commit comments

Comments
 (0)