From 2b85a2c69d6ddf1a66bcc363a676b243c790678a Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Wed, 24 Jul 2019 10:46:26 +0300 Subject: [PATCH 1/3] graphQl-786: fixed the quantity field in the bundle product --- .../BundleGraphQl/Model/Resolver/Links/Collection.php | 2 +- app/code/Magento/BundleGraphQl/etc/schema.graphqls | 2 +- .../Magento/GraphQl/Bundle/BundleProductViewTest.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php index ee695c319501..74769e5d56b5 100644 --- a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php +++ b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php @@ -117,7 +117,7 @@ private function fetch() : array 'price' => $link->getSelectionPriceValue(), 'position' => $link->getPosition(), 'id' => $link->getSelectionId(), - 'qty' => (int)$link->getSelectionQty(), + 'quantity' => (int)$link->getSelectionQty(), 'is_default' => (bool)$link->getIsDefault(), 'price_type' => $this->enumLookup->getEnumValueFromField( 'PriceTypeEnum', diff --git a/app/code/Magento/BundleGraphQl/etc/schema.graphqls b/app/code/Magento/BundleGraphQl/etc/schema.graphqls index 26d2cbcd704f..e00a0b43c2e5 100644 --- a/app/code/Magento/BundleGraphQl/etc/schema.graphqls +++ b/app/code/Magento/BundleGraphQl/etc/schema.graphqls @@ -14,7 +14,7 @@ type BundleItem @doc(description: "BundleItem defines an individual item in a bu type BundleItemOption @doc(description: "BundleItemOption defines characteristics and options for a specific bundle item.") { id: Int @doc(description: "The ID assigned to the bundled item option.") label: String @doc(description: "The text that identifies the bundled item option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Label") - qty: Float @doc(description: "Indicates the quantity of this specific bundle item.") + quantity: Float @doc(description: "Indicates the quantity of this specific bundle item.") position: Int @doc(description: "When a bundle item contains multiple options, the relative position of this option compared to the other options.") is_default: Boolean @doc(description: "Indicates whether this option is the default option.") price: Float @doc(description: "The price of the selected option.") diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php index d5d34e48d77c..32526f1b6a78 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php @@ -58,7 +58,7 @@ public function testAllFieldsBundleProducts() sku options { id - qty + quantity position is_default price @@ -143,7 +143,7 @@ public function testBundleProductWithNotVisibleChildren() sku options { id - qty + quantity position is_default price @@ -269,7 +269,7 @@ private function assertBundleProductOptions($product, $actualResponse) $actualResponse['items'][0]['options'][0], [ 'id' => $bundleProductLink->getId(), - 'qty' => (int)$bundleProductLink->getQty(), + 'quantity' => (int)$bundleProductLink->getQty(), 'position' => $bundleProductLink->getPosition(), 'is_default' => (bool)$bundleProductLink->getIsDefault(), 'price_type' => self::KEY_PRICE_TYPE_FIXED, From 1f06deaf705ee170e588c82f67e0c7f9ddfeb816 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 08:58:31 +0300 Subject: [PATCH 2/3] graphQl-786: deprecated qty --- .../BundleGraphQl/Model/Resolver/Links/Collection.php | 1 + app/code/Magento/BundleGraphQl/etc/schema.graphqls | 1 + .../Magento/GraphQl/Bundle/BundleProductViewTest.php | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php index 74769e5d56b5..5c8c09a93042 100644 --- a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php +++ b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php @@ -117,6 +117,7 @@ private function fetch() : array 'price' => $link->getSelectionPriceValue(), 'position' => $link->getPosition(), 'id' => $link->getSelectionId(), + 'qty' => (int)$link->getSelectionQty(), 'quantity' => (int)$link->getSelectionQty(), 'is_default' => (bool)$link->getIsDefault(), 'price_type' => $this->enumLookup->getEnumValueFromField( diff --git a/app/code/Magento/BundleGraphQl/etc/schema.graphqls b/app/code/Magento/BundleGraphQl/etc/schema.graphqls index e00a0b43c2e5..74e21d3feaba 100644 --- a/app/code/Magento/BundleGraphQl/etc/schema.graphqls +++ b/app/code/Magento/BundleGraphQl/etc/schema.graphqls @@ -14,6 +14,7 @@ type BundleItem @doc(description: "BundleItem defines an individual item in a bu type BundleItemOption @doc(description: "BundleItemOption defines characteristics and options for a specific bundle item.") { id: Int @doc(description: "The ID assigned to the bundled item option.") label: String @doc(description: "The text that identifies the bundled item option.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Options\\Label") + qty: Float @deprecated(reason: "The `qty` is deprecated. Use `quantity` instead.") @doc(description: "Indicates the quantity of this specific bundle item.") quantity: Float @doc(description: "Indicates the quantity of this specific bundle item.") position: Int @doc(description: "When a bundle item contains multiple options, the relative position of this option compared to the other options.") is_default: Boolean @doc(description: "Indicates whether this option is the default option.") diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php index 32526f1b6a78..5d08078cf764 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/BundleProductViewTest.php @@ -428,8 +428,9 @@ public function testNonExistentFieldQtyExceptionOnBundleProduct() QUERY; $this->expectException(\Exception::class); - $this->expectExceptionMessage('GraphQL response contains errors: Cannot'. ' ' . - 'query field "qty" on type "ProductInterface".'); + $this->expectExceptionMessage( + 'GraphQL response contains errors: Cannot query field "qty" on type "ProductInterface".' + ); $this->graphQlQuery($query); } } From 53a03252623eedf7c0c8ad01821e7f8287c174a6 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 08:59:26 +0300 Subject: [PATCH 3/3] graphQl-786: fixed type --- .../Magento/BundleGraphQl/Model/Resolver/Links/Collection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php index 5c8c09a93042..13bf10bc6aca 100644 --- a/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php +++ b/app/code/Magento/BundleGraphQl/Model/Resolver/Links/Collection.php @@ -117,8 +117,8 @@ private function fetch() : array 'price' => $link->getSelectionPriceValue(), 'position' => $link->getPosition(), 'id' => $link->getSelectionId(), - 'qty' => (int)$link->getSelectionQty(), - 'quantity' => (int)$link->getSelectionQty(), + 'qty' => (float)$link->getSelectionQty(), + 'quantity' => (float)$link->getSelectionQty(), 'is_default' => (bool)$link->getIsDefault(), 'price_type' => $this->enumLookup->getEnumValueFromField( 'PriceTypeEnum',