From 6681a87cc249b7b8f3ee33c501734319a043feff Mon Sep 17 00:00:00 2001 From: Hans Nieser Date: Wed, 31 Jan 2024 14:41:14 +0100 Subject: [PATCH 1/5] Document patch for custom options not saving --- docs/magento/known-issues.md | 28 +++++++++++++++++++ .../fix-custom-option-processing.patch | 23 +++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docs/magento/patches/fix-custom-option-processing.patch diff --git a/docs/magento/known-issues.md b/docs/magento/known-issues.md index 9031be4835..682e7f2318 100644 --- a/docs/magento/known-issues.md +++ b/docs/magento/known-issues.md @@ -24,6 +24,34 @@ As a workaround, you can apply See also https://github.com/magento/magento2/commit/49cbe774020d3dfa6ee2b8702376a947801c9971 +## After adding a product to cart with custom options, options are not saved and/or retrieving the cart results in an error + +Affected Magento versions: + +- `2.4.7`: all versions +- `2.4.6`: all versions + +When adding a product to cart, custom options are not processed and saved +correctly, and can result in an error on the `Cart.items.errors.message` field +when subsequently retrieving the cart, if the product had required custom +options. + +The observed error happens because no value is given for the non-nullable +`message` field, however the original error occurs due a required custom option +not being present on the cart item, as the custom options we not saved correctly +during the previous `addProductsToCart` call. + +Note that although the relevant PR for this fix was merged, the fix seems to +have gotten reverted and is not present in 2.4-develop at the time of writing. + +As a workaround, you can apply +[fix-custom-option-processing.patch](./patches/fix-custom-option-processing.patch). + +See also: + +- Original PR: https://github.com/magento/magento2/issues/37599 +- PR regarding revert of fix: https://github.com/magento/magento2/issues/37928 + ## Next steps - [Overview](./readme) diff --git a/docs/magento/patches/fix-custom-option-processing.patch b/docs/magento/patches/fix-custom-option-processing.patch new file mode 100644 index 0000000000..589fdc8d9f --- /dev/null +++ b/docs/magento/patches/fix-custom-option-processing.patch @@ -0,0 +1,23 @@ +From ae5c89e5af2c14dea33b5c5d49ead84d55fd02f8 Mon Sep 17 00:00:00 2001 +From: Shomi Adarsh +Date: Thu, 22 Jun 2023 13:48:07 +0530 +Subject: [PATCH] GraphQL cannot add product with customizable option to cart + #37599 + +--- + app/code/Magento/Quote/Model/Quote.php | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Model/Quote.php b/Model/Quote.php +index 572d87d5f4bec..6a2575d974336 100644 +--- a/Model/Quote.php ++++ b/Model/Quote.php +@@ -1647,6 +1647,8 @@ public function addProduct( + ); + } + ++ $productId = $product->getId(); ++ $product = clone $this->productRepository->getById($productId, false, $this->getStore()->getId()); + $cartCandidates = $product->getTypeInstance()->prepareForCartAdvanced($request, $product, $processMode); + + /** \ No newline at end of file From 82b994e2683a1ecf5c07a8e228fe7be575b4dd72 Mon Sep 17 00:00:00 2001 From: Hans Nieser Date: Wed, 31 Jan 2024 16:10:34 +0100 Subject: [PATCH 2/5] Document add-to-cart error handling issue+patch --- docs/magento/known-issues.md | 25 ++++++++++++++++--- .../fix-cart-user-error-reporting.patch | 21 ++++++++++++++++ .../fix-custom-option-processing.patch | 12 ++------- 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 docs/magento/patches/fix-cart-user-error-reporting.patch diff --git a/docs/magento/known-issues.md b/docs/magento/known-issues.md index 682e7f2318..a85e98bfeb 100644 --- a/docs/magento/known-issues.md +++ b/docs/magento/known-issues.md @@ -10,7 +10,6 @@ An overview of bugs and limitations you may run into with Magento's GraphQL API: Affected Magento versions: -- `2.4.7`: only `2.4.7-beta1` - `2.4.6`: all versions This is caused by a regression which results in some GraphQL errors no longer @@ -28,7 +27,6 @@ https://github.com/magento/magento2/commit/49cbe774020d3dfa6ee2b8702376a947801c9 Affected Magento versions: -- `2.4.7`: all versions - `2.4.6`: all versions When adding a product to cart, custom options are not processed and saved @@ -42,7 +40,8 @@ not being present on the cart item, as the custom options we not saved correctly during the previous `addProductsToCart` call. Note that although the relevant PR for this fix was merged, the fix seems to -have gotten reverted and is not present in 2.4-develop at the time of writing. +have gotten reverted and is not present in 2.4-develop at the time of writing, +and may not be included in the final release of 2.4.7. As a workaround, you can apply [fix-custom-option-processing.patch](./patches/fix-custom-option-processing.patch). @@ -52,6 +51,26 @@ See also: - Original PR: https://github.com/magento/magento2/issues/37599 - PR regarding revert of fix: https://github.com/magento/magento2/issues/37928 +## Adding products to cart with pre-existing items that are out of stock, always results in an error + +Affected Magento versions: + +- `2.4.7`: fixed after 2.4.7-beta2 +- `2.4.6`: all versions + +This is due to an inconsistency between errors that are reported through the +`AddProductsToCartOutput.user_errors` field and those on the cart items, which +make it impossible to differentiate between errors cause by the product that was +being added, and those from pre-existing cart items. + +As a workaround you can apply +[fix-cart-user-error-reporting.patch](./patches/fix-cart-user-error-reporting.patch). + +See also: + +- Issue: https://github.com/magento/magento2/issues/37908 +- PR with fix: https://github.com/magento/magento2/pull/38014/files + ## Next steps - [Overview](./readme) diff --git a/docs/magento/patches/fix-cart-user-error-reporting.patch b/docs/magento/patches/fix-cart-user-error-reporting.patch new file mode 100644 index 0000000000..767836706b --- /dev/null +++ b/docs/magento/patches/fix-cart-user-error-reporting.patch @@ -0,0 +1,21 @@ +Fix add to cart `user_error` field containing inconsistent errors. See https://github.com/magento/magento2/pull/38014 + +@package magento/module-quote + +--- a/Model/Cart/AddProductsToCart.php ++++ b/Model/Cart/AddProductsToCart.php (date 1696845624268) +@@ -80,14 +80,6 @@ + $cartId = $this->maskedQuoteIdToQuoteId->execute($maskedCartId); + $cart = $this->cartRepository->get($cartId); + $allErrors = []; +- if ($cart->getData('has_error')) { +- $errors = $cart->getErrors(); +- +- /** @var MessageInterface $error */ +- foreach ($errors as $error) { +- $allErrors[] = $this->error->create($error->getText()); +- } +- } + + $failedCartItems = $this->addItemsToCart($cart, $cartItems); + $saveCart = empty($failedCartItems); \ No newline at end of file diff --git a/docs/magento/patches/fix-custom-option-processing.patch b/docs/magento/patches/fix-custom-option-processing.patch index 589fdc8d9f..473c6cc07b 100644 --- a/docs/magento/patches/fix-custom-option-processing.patch +++ b/docs/magento/patches/fix-custom-option-processing.patch @@ -1,15 +1,7 @@ -From ae5c89e5af2c14dea33b5c5d49ead84d55fd02f8 Mon Sep 17 00:00:00 2001 -From: Shomi Adarsh -Date: Thu, 22 Jun 2023 13:48:07 +0530 -Subject: [PATCH] GraphQL cannot add product with customizable option to cart - #37599 +Fix custom options not saving on addProductsToCart. See https://github.com/magento/magento2/issues/37599 ---- - app/code/Magento/Quote/Model/Quote.php | 2 ++ - 1 file changed, 2 insertions(+) +@package magento/module-quote -diff --git a/Model/Quote.php b/Model/Quote.php -index 572d87d5f4bec..6a2575d974336 100644 --- a/Model/Quote.php +++ b/Model/Quote.php @@ -1647,6 +1647,8 @@ public function addProduct( From d6b24c52dc084f59165e86b164fe99c409a236a8 Mon Sep 17 00:00:00 2001 From: Hans Nieser Date: Wed, 31 Jan 2024 16:21:06 +0100 Subject: [PATCH 3/5] Clarify status of known issues in 2.4.7 --- docs/magento/known-issues.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/magento/known-issues.md b/docs/magento/known-issues.md index a85e98bfeb..c6d414eeed 100644 --- a/docs/magento/known-issues.md +++ b/docs/magento/known-issues.md @@ -10,6 +10,7 @@ An overview of bugs and limitations you may run into with Magento's GraphQL API: Affected Magento versions: +- `2.4.7`: fixed after 2.4.7-beta1 - `2.4.6`: all versions This is caused by a regression which results in some GraphQL errors no longer @@ -27,6 +28,7 @@ https://github.com/magento/magento2/commit/49cbe774020d3dfa6ee2b8702376a947801c9 Affected Magento versions: +- `2.4.7`: unknown, see below - `2.4.6`: all versions When adding a product to cart, custom options are not processed and saved @@ -51,7 +53,7 @@ See also: - Original PR: https://github.com/magento/magento2/issues/37599 - PR regarding revert of fix: https://github.com/magento/magento2/issues/37928 -## Adding products to cart with pre-existing items that are out of stock, always results in an error +## Adding products to cart with pre-existing items that are out of stock always results in an error Affected Magento versions: From 1745cd037742fc7b0e9a4d4556985edcc86f52d8 Mon Sep 17 00:00:00 2001 From: Hans Nieser Date: Thu, 1 Feb 2024 11:39:05 +0100 Subject: [PATCH 4/5] Document patch for bundle selection product visibility issue --- docs/magento/known-issues.md | 17 +++++++++++++++++ ...-bundle-selection-visibility-catalog.patch | 17 +++++++++++++++++ ...-bundle-selection-visibility-related.patch | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 docs/magento/patches/fix-bundle-selection-visibility-catalog.patch create mode 100644 docs/magento/patches/fix-bundle-selection-visibility-related.patch diff --git a/docs/magento/known-issues.md b/docs/magento/known-issues.md index c6d414eeed..bf386f3f6d 100644 --- a/docs/magento/known-issues.md +++ b/docs/magento/known-issues.md @@ -73,6 +73,23 @@ See also: - Issue: https://github.com/magento/magento2/issues/37908 - PR with fix: https://github.com/magento/magento2/pull/38014/files +## Bundle selection products are not shown due to their visibility setting + +Affected Magento versions: + +- `2.4.6`: all versions + +The `BundleItemOption.product` GraphQL field is returned as `null` if the +product visibility is set to not be visible in the catalog (which you may not +want). + +As a workaround you can apply the following patches: + +- [fix-bundle-selection-visibility-catalog.patch](./patches/fix-bundle-selection-visibility-catalog.patch) +- [fix-bundle-selection-visibility-related.patch](./patches/fix-bundle-selection-visibility-related.patch) + +See also https://github.com/magento/magento2/issues/37774 + ## Next steps - [Overview](./readme) diff --git a/docs/magento/patches/fix-bundle-selection-visibility-catalog.patch b/docs/magento/patches/fix-bundle-selection-visibility-catalog.patch new file mode 100644 index 0000000000..3edd69cf60 --- /dev/null +++ b/docs/magento/patches/fix-bundle-selection-visibility-catalog.patch @@ -0,0 +1,17 @@ +Fix bundle product children not showing up on some products, see https://github.com/magento/magento2/issues/37774 + +@package magento/module-catalog-graph-ql + +diff --git a/Model/Resolver/Products/DataProvider/Product.php b/Model/Resolver/Products/DataProvider/Product.php +index 30be41072242b..3e955ae303453 100644 +--- a/Model/Resolver/Products/DataProvider/Product.php ++++ b/Model/Resolver/Products/DataProvider/Product.php +@@ -89,7 +89,7 @@ public function getList( + + $this->collectionPreProcessor->process($collection, $searchCriteria, $attributes, $context); + +- if ($isChildSearch) { ++ if (!$isChildSearch) { + $visibilityIds = $isSearch + ? $this->visibility->getVisibleInSearchIds() + : $this->visibility->getVisibleInCatalogIds(); diff --git a/docs/magento/patches/fix-bundle-selection-visibility-related.patch b/docs/magento/patches/fix-bundle-selection-visibility-related.patch new file mode 100644 index 0000000000..c7265e8023 --- /dev/null +++ b/docs/magento/patches/fix-bundle-selection-visibility-related.patch @@ -0,0 +1,19 @@ +Fix bundle product children not showing up on some products, see https://github.com/magento/magento2/issues/37774 + +@package magento/module-related-product-graph-ql + +diff --git a/Model/Resolver/Batch/AbstractLikedProducts.php b/Model/Resolver/Batch/AbstractLikedProducts.php +index fac7b23d408e3..f35af6f4885d2 100644 +--- a/Model/Resolver/Batch/AbstractLikedProducts.php ++++ b/Model/Resolver/Batch/AbstractLikedProducts.php +@@ -94,9 +94,7 @@ private function findRelations(array $products, array $loadAttributes, int $link + $this->searchCriteriaBuilder->addFilter('entity_id', $relatedIds, 'in'); + $relatedSearchResult = $this->productDataProvider->getList( + $this->searchCriteriaBuilder->create(), +- $loadAttributes, +- false, +- true ++ $loadAttributes + ); + //Filling related products map. + /** @var \Magento\Catalog\Api\Data\ProductInterface[] $relatedProducts */ From 09eb25c9892bf4cf57519024e31c2ae4cf2f7a0b Mon Sep 17 00:00:00 2001 From: Paul Hachmang Date: Fri, 2 Feb 2024 00:16:46 +0100 Subject: [PATCH 5/5] Create good-rocks-matter.md --- .changeset/good-rocks-matter.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/good-rocks-matter.md diff --git a/.changeset/good-rocks-matter.md b/.changeset/good-rocks-matter.md new file mode 100644 index 0000000000..74ff8ac708 --- /dev/null +++ b/.changeset/good-rocks-matter.md @@ -0,0 +1,5 @@ +--- +"@graphcommerce/docs": patch +--- + +Update Magento known issues