Skip to content

Commit b1b9478

Browse files
authored
ENGCOM-5492: graphQl-786: fixed the quantity field in the bundle item option #788
2 parents 968737f + d365c0a commit b1b9478

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private function fetch() : array
117117
'price' => $link->getSelectionPriceValue(),
118118
'position' => $link->getPosition(),
119119
'id' => $link->getSelectionId(),
120-
'qty' => (int)$link->getSelectionQty(),
120+
'qty' => (float)$link->getSelectionQty(),
121+
'quantity' => (float)$link->getSelectionQty(),
121122
'is_default' => (bool)$link->getIsDefault(),
122123
'price_type' => $this->enumLookup->getEnumValueFromField(
123124
'PriceTypeEnum',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ type BundleItem @doc(description: "BundleItem defines an individual item in a bu
1414
type BundleItemOption @doc(description: "BundleItemOption defines characteristics and options for a specific bundle item.") {
1515
id: Int @doc(description: "The ID assigned to the bundled item option.")
1616
label: String @doc(description: "The text that identifies the bundled item option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Label")
17-
qty: Float @doc(description: "Indicates the quantity of this specific bundle item.")
17+
qty: Float @deprecated(reason: "The `qty` is deprecated. Use `quantity` instead.") @doc(description: "Indicates the quantity of this specific bundle item.")
18+
quantity: Float @doc(description: "Indicates the quantity of this specific bundle item.")
1819
position: Int @doc(description: "When a bundle item contains multiple options, the relative position of this option compared to the other options.")
1920
is_default: Boolean @doc(description: "Indicates whether this option is the default option.")
2021
price: Float @doc(description: "The price of the selected option.")

dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testAllFieldsBundleProducts()
5858
sku
5959
options {
6060
id
61-
qty
61+
quantity
6262
position
6363
is_default
6464
price
@@ -143,7 +143,7 @@ public function testBundleProductWithNotVisibleChildren()
143143
sku
144144
options {
145145
id
146-
qty
146+
quantity
147147
position
148148
is_default
149149
price
@@ -269,7 +269,7 @@ private function assertBundleProductOptions($product, $actualResponse)
269269
$actualResponse['items'][0]['options'][0],
270270
[
271271
'id' => $bundleProductLink->getId(),
272-
'qty' => (int)$bundleProductLink->getQty(),
272+
'quantity' => (int)$bundleProductLink->getQty(),
273273
'position' => $bundleProductLink->getPosition(),
274274
'is_default' => (bool)$bundleProductLink->getIsDefault(),
275275
'price_type' => self::KEY_PRICE_TYPE_FIXED,
@@ -428,8 +428,9 @@ public function testNonExistentFieldQtyExceptionOnBundleProduct()
428428
QUERY;
429429

430430
$this->expectException(\Exception::class);
431-
$this->expectExceptionMessage('GraphQL response contains errors: Cannot'. ' ' .
432-
'query field "qty" on type "ProductInterface".');
431+
$this->expectExceptionMessage(
432+
'GraphQL response contains errors: Cannot query field "qty" on type "ProductInterface".'
433+
);
433434
$this->graphQlQuery($query);
434435
}
435436
}

0 commit comments

Comments
 (0)