Skip to content

Commit

Permalink
Fixed issue with tier price issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 committed Mar 3, 2021
1 parent 81ad0b4 commit 3359cfa
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Api\Data\StoreInterface;

/**
* Resolver for price_tiers
Expand Down Expand Up @@ -125,6 +124,10 @@ public function resolve(
return [];
}

if (!$product->getTierPrices()) {
return [];
}

$productId = (int)$product->getId();
$this->tiers->addProductFilter($productId);

Expand Down Expand Up @@ -152,7 +155,7 @@ private function formatAndFilterTierPrices(
array $tierPrices,
string $currencyCode
): array {

$this->resetFormatAndFilterTierPrices();
foreach ($tierPrices as $key => $tierPrice) {
$tierPrice->setValue($this->priceCurrency->convertAndRound($tierPrice->getValue()));
$this->formatTierPrices($productPrice, $currencyCode, $tierPrice);
Expand Down Expand Up @@ -212,4 +215,14 @@ private function filterTierPrices(
$this->tierPricesQty[$qty] = $key;
}
}

/**
* Remove all element from formatAndFilterTierPrices
*/
private function resetFormatAndFilterTierPrices()
{
foreach ($this->formatAndFilterTierPrices as $key => $value) {
unset($this->formatAndFilterTierPrices[$key]);
}
}
}

0 comments on commit 3359cfa

Please sign in to comment.