Skip to content

Commit 3359cfa

Browse files
committed
Fixed issue with tier price issue
1 parent 81ad0b4 commit 3359cfa

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Magento\Framework\GraphQl\Query\ResolverInterface;
2020
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2121
use Magento\Framework\Pricing\PriceCurrencyInterface;
22-
use Magento\Store\Api\Data\StoreInterface;
2322

2423
/**
2524
* Resolver for price_tiers
@@ -125,6 +124,10 @@ public function resolve(
125124
return [];
126125
}
127126

127+
if (!$product->getTierPrices()) {
128+
return [];
129+
}
130+
128131
$productId = (int)$product->getId();
129132
$this->tiers->addProductFilter($productId);
130133

@@ -152,7 +155,7 @@ private function formatAndFilterTierPrices(
152155
array $tierPrices,
153156
string $currencyCode
154157
): array {
155-
158+
$this->resetFormatAndFilterTierPrices();
156159
foreach ($tierPrices as $key => $tierPrice) {
157160
$tierPrice->setValue($this->priceCurrency->convertAndRound($tierPrice->getValue()));
158161
$this->formatTierPrices($productPrice, $currencyCode, $tierPrice);
@@ -212,4 +215,14 @@ private function filterTierPrices(
212215
$this->tierPricesQty[$qty] = $key;
213216
}
214217
}
218+
219+
/**
220+
* Remove all element from formatAndFilterTierPrices
221+
*/
222+
private function resetFormatAndFilterTierPrices()
223+
{
224+
foreach ($this->formatAndFilterTierPrices as $key => $value) {
225+
unset($this->formatAndFilterTierPrices[$key]);
226+
}
227+
}
215228
}

0 commit comments

Comments
 (0)