Skip to content

Commit 37754f6

Browse files
committed
MC-18403: Pricing :: Product pricing schema
- fix variant tier prices
1 parent 9d505e8 commit 37754f6

File tree

1 file changed

+22
-1
lines changed
  • app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price

1 file changed

+22
-1
lines changed

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price/Tiers.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ public function getProductRegularPrice($productId): ?float
127127
*/
128128
public function isLoaded(): bool
129129
{
130+
$numFilterProductIds = count(array_unique($this->filterProductIds));
131+
if ($numFilterProductIds > count($this->products)) {
132+
//New products were added to the filter after load, so we should reload
133+
return false;
134+
}
130135
return $this->loaded;
131136
}
132137

@@ -146,10 +151,26 @@ private function load(): void
146151
$productCollection->load();
147152
$productCollection->addTierPriceDataByGroupId($this->customerGroupId);
148153

154+
$this->setProducts($productCollection);
155+
$this->loaded = true;
156+
}
157+
158+
/**
159+
* Set products from collection
160+
*
161+
* @param Collection $productCollection
162+
*/
163+
private function setProducts(Collection $productCollection): void
164+
{
165+
$this->products = [];
166+
149167
foreach ($productCollection as $product) {
150168
$this->products[$product->getId()] = $product;
151169
}
152170

153-
$this->loaded = true;
171+
$missingProducts = array_diff($this->filterProductIds, array_keys($this->products));
172+
foreach (array_unique($missingProducts) as $missingProductId) {
173+
$this->products[$missingProductId] = null;
174+
}
154175
}
155176
}

0 commit comments

Comments
 (0)