From 7dc9e6469c34221aabec3ca9083ed62239e0554b Mon Sep 17 00:00:00 2001 From: Tomash Khamlai Date: Fri, 11 Oct 2019 17:52:18 +0300 Subject: [PATCH 1/2] Remove try-catch construction As long as ```graphql type Mutation { addDownloadableProductsToCart(input: AddDownloadableProductsToCartInput): AddDownloadableProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart") } ``` is not changed, this exception caching is a duplicate of one that is in \Magento\QuoteGraphQl\Model\Resolver\AddSimpleProductsToCart::execute(); Signed-off-by: Tomash Khamlai --- .../Cart/BuyRequest/DownloadableLinksDataProvider.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php b/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php index 18f883b61516..5f159971e4a1 100644 --- a/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php +++ b/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php @@ -40,12 +40,7 @@ public function execute(array $cartItemData): array if (isset($cartItemData['data']) && isset($cartItemData['data']['sku'])) { $sku = $cartItemData['data']['sku']; - - try { - $product = $this->productRepository->get($sku); - } catch (NoSuchEntityException $e) { - throw new GraphQlNoSuchEntityException(__('Could not find specified product.')); - } + $product = $this->productRepository->get($sku); if ($product->getLinksPurchasedSeparately() && isset($cartItemData['downloadable_product_links'])) { $downloadableLinks = $cartItemData['downloadable_product_links']; From f45a6728e44f0e7b347072d77755f166dc953816 Mon Sep 17 00:00:00 2001 From: Tomash Khamlai Date: Fri, 11 Oct 2019 19:57:47 +0300 Subject: [PATCH 2/2] Change Exception message for testAddNonExistentConfigurableProductVariationToCart Signed-off-by: Tomash Khamlai --- .../ConfigurableProduct/AddConfigurableProductToCartTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php index 39b69f86cbe1..b1858e843bf0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php @@ -265,7 +265,8 @@ public function testAddNonExistentConfigurableProductVariationToCart() $this->expectException(\Exception::class); $this->expectExceptionMessage( - 'Could not add the product with SKU configurable to the shopping cart: Could not find specified product.' + 'Could not add the product with SKU configurable to the shopping cart: The product that was requested ' . + 'doesn\'t exist. Verify the product and try again.' ); $this->graphQlMutation($query);