Skip to content

Commit a8e63e6

Browse files
committed
Merge remote-tracking branch 'origin/MC-18403' into MC-20244
2 parents a32d0db + f9c4705 commit a8e63e6

File tree

6 files changed

+571
-87
lines changed

6 files changed

+571
-87
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
}

app/code/Magento/CatalogCustomerGraphQl/etc/schema.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type ProductTierPrices @doc(description: "ProductTierPrices is deprecated and ha
1515
}
1616

1717

18-
type TierPrice @doc(description: "TierPrice defines a tier price, which is a price offered based on a particular quantity purchased.") {
18+
type TierPrice @doc(description: "A price based on the quantity purchased.") {
1919
final_price: Money @doc(desription: "The price of the product at this tier.")
20-
quantity: Float @doc(description: "The number of items that must be purchased to qualify for this price tier.")
20+
quantity: Float @doc(description: "The minimum number of items that must be purchased to qualify for this price tier.")
2121
discount: ProductDiscount @doc(description: "The price discount that this tier represents.")
2222
}

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ enum PriceTypeEnum @doc(description: "This enumeration the price type.") {
4141
DYNAMIC
4242
}
4343

44-
type ProductPrices @deprecated(reason: "Use PriceRange instead.") @doc(description: "The ProductPrices object contains the regular price of an item, as well as its minimum and maximum prices. Only composite products, which include bundle, configurable, and grouped products, can contain a minimum and maximum price.") {
44+
type ProductPrices @doc(description: "ProductPrices is deprecated, replaced by PriceRange. The ProductPrices object contains the regular price of an item, as well as its minimum and maximum prices. Only composite products, which include bundle, configurable, and grouped products, can contain a minimum and maximum price.") {
4545
minimalPrice: Price @deprecated(reason: "Use PriceRange.minimum_price.") @doc(description: "The lowest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the from value.")
4646
maximalPrice: Price @deprecated(reason: "Use PriceRange.maximum_price.") @doc(description: "The highest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the to value.")
4747
regularPrice: Price @deprecated(reason: "Use regular_price from PriceRange.minimum_price or PriceRange.maximum_price.") @doc(description: "The base price of a product.")
4848
}
4949

50-
type PriceRange @doc(description: "Price range for a product. If the product only has a single price minimum and maximum price will be the same."){
50+
type PriceRange @doc(description: "Price range for a product. If the product has a single price, the minimum and maximum price will be the same."){
5151
minimum_price: ProductPrice! @doc(description: "The lowest possible price for the product.")
5252
maximum_price: ProductPrice @doc(description: "The highest possible price for the product.")
5353
}
@@ -58,9 +58,9 @@ type ProductPrice @doc(description: "Represents a product price.") {
5858
discount: ProductDiscount @doc(description: "The price discount. Represents the difference between the regular and final price.")
5959
}
6060

61-
type ProductDiscount @doc(description: "Price discount applied to a product.") {
62-
percent_off: Float @doc(description: "The discount expressed a percent value.")
63-
amount_off: Float @doc(description: "The discount expressed an absolute value.")
61+
type ProductDiscount @doc(description: "A discount applied to a product price.") {
62+
percent_off: Float @doc(description: "The discount expressed a percentage.")
63+
amount_off: Float @doc(description: "The actual value of the discount.")
6464
}
6565

6666
type ProductLinks implements ProductLinksInterface @doc(description: "ProductLinks is an implementation of ProductLinksInterface.") {

0 commit comments

Comments
 (0)