Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql - issue adding multiple configurable products to cart #30948

Closed
5 tasks
calin-ImDigital opened this issue Nov 17, 2020 · 18 comments · Fixed by nige-one/magento2#1 or #31654
Closed
5 tasks

Graphql - issue adding multiple configurable products to cart #30948

calin-ImDigital opened this issue Nov 17, 2020 · 18 comments · Fixed by nige-one/magento2#1 or #31654
Assignees
Labels
Area: Cart & Checkout Component: GraphQL GraphQL Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@calin-ImDigital
Copy link

Preconditions (*)

  1. magento 2.3.4

Steps to reproduce (*)

create a mutation for addConfigurableProductsToCart with multiple configurable products

Expected result (*)

  1. products added to cart

Actual result (*)

{
"errors": [
{
"message": "You need to choose options for your item.",
"extensions": {
"category": "graphql-input"
},
"locations": [
{
"line": 25,
"column": 3
}
],
"path": [
"addConfigurableProductsToCart"
]
}
],
"data": {
"addConfigurableProductsToCart": null
}
}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Nov 17, 2020

Hi @cdiacon-img. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@nige-one
Copy link
Contributor

I have the same issue. The problem is that in

if (empty($this->productIds) || !empty($this->attributeMap)) {

the !empty($this->attributeMap) does not take into account the case of more then one Configurable Product's super attribute needs to be resolved.

@m2-assistant
Copy link

m2-assistant bot commented Feb 10, 2021

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo
Copy link
Contributor

Hello @cdiacon-img

Thank you for your report.

Can you please clarify, are you trying to add multiple Products with options using one mutation, or you are trying to add one single configurable product with multiple options?
In any case, could you please provide a mutation example?

Thank you in advance

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Feb 10, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Feb 10, 2021
@calin-ImDigital
Copy link
Author

Hi @engcom-Bravo

As I remember it was adding multiple products(cart items) with this mutation

mutation {
#   addConfigurableProductsToCart(
#     input: {
#       cart_id: "QZBii1Eu3vb5tOoGo94Rl9kcnquhc1Nf"
#       cart_items: [
#         {
#           data: {
#             quantity: 1
#             sku: "40012244"
#           },
#           parent_sku: "style-123"
            
#         },
#         {
#           parent_sku: "style-321"
#           data:{
#             quantity: 2
#             sku: "40023175"
#           }
          
#         }
#       ]
#     }
#   ) {
#     cart {
#       items {
#         id
#         product {
#           sku
#           stock_status
#         }
#         quantity
#       }
#     }
#   }
# }

@engcom-Bravo
Copy link
Contributor

@cdiacon-img Thank you for the quick response.

This actually was the mutation we have tried to reproduce with.
The difference is that we are getting a different error

{
  "errors": [
    {
      "message": "Could not add the product with SKU Configurable2 to the shopping cart: Could not find specified product.",
      "extensions": {
        "category": "graphql-input"

This happens when we try to add two products. The Configurable2 itself is added to the Cart successfully.

@calin-ImDigital
Copy link
Author

@engcom-Bravo

I am not sure why you are getting product not found but I guess you are hitting the condition of this test

testAddVariationFromAnotherConfigurableProductWithTheSameSuperAttributeToCart

But in my case it was getting attribute data from wrong product
You need to choose options for your item

This is how we patched at the moment, I hope this helps :

---
 vendor/magento/module-configurable-product-graph-ql/Model/Options/Collection.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vendor/magento/module-configurable-product-graph-ql/Model/Options/Collection.php b/vendor/magento/module-configurable-product-graph-ql/Model/Options/Collection.php
index 36ee00d..c8bbe74 100644
--- a/vendor/magento/module-configurable-product-graph-ql/Model/Options/Collection.php
+++ b/vendor/magento/module-configurable-product-graph-ql/Model/Options/Collection.php
@@ -97,7 +97,7 @@ class Collection
      */
     private function fetch() : array
     {
-        if (empty($this->productIds) || !empty($this->attributeMap)) {
+        if (empty($this->productIds)) {
             return $this->attributeMap;
         }

--

@calin-ImDigital
Copy link
Author

This is the same thing that @nige-one pointed out above.

@engcom-Bravo
Copy link
Contributor

Hello @cdiacon-img

I'm still getting a different error than the reported.
The following mutation

mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "nUdFfPMkIyC3vJS8I6K56Tk0zdPDUpco"
      cart_items: [
        { parent_sku: "Conf1", data: { quantity: 1, sku: "Conf1-white" } }
        { parent_sku: "Conf2", data: { quantity: 1, sku: "Conf2-s" } }
      ]
    }
  ) {
    cart {
      items {
        uid
        quantity
        product {
          name
          sku
        }
        ... on ConfigurableCartItem {
          configurable_options {
            option_label
          }
        }
      }
    }
  }
}

returns

{
  "errors": [
    {
      "message": "Could not add the product with SKU Conf2 to the shopping cart: The product with SKU Conf2 is out of stock.",
      "extensions": {
        "category": "graphql-input"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "addConfigurableProductsToCart"
      ]
    }
  ],
  "data": {
    "addConfigurableProductsToCart": null
  }
}

It might be that on 2.4-develop the behavior is different. I noticed that you are reporting the issue on 2.3.4. Can you please verify if the issue is reproducible on 2.4-develop for you?

Thank you

@engcom-Bravo engcom-Bravo removed their assignment Mar 2, 2021
@sivaschenko sivaschenko added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Mar 9, 2021
@m2-community-project m2-community-project bot added this to Pull Request In Progress in High Priority Backlog Mar 9, 2021
@engcom-Alfa engcom-Alfa added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: needs update Additional information is require, waiting for response labels Aug 23, 2021
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 23, 2021
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@engcom-Alfa engcom-Alfa added the Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch label Aug 23, 2021
@engcom-Alfa engcom-Alfa added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 23, 2021
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 23, 2021
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@engcom-Alfa engcom-Alfa added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 23, 2021
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 23, 2021
@engcom-Alfa engcom-Alfa added Area: Cart & Checkout Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 23, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-959 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 23, 2021

✅ Confirmed by @engcom-Alfa. Thank you for verifying the issue.
Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-959

1 similar comment
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-959

@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Aug 25, 2021
@sidolov sidolov added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Oct 24, 2021
@sidolov
Copy link
Contributor

sidolov commented Oct 24, 2021

Hi @cdiacon-img. Thank you for your report.
The issue has been fixed in #31654 by @nige-one in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.3 release.

@sidolov sidolov closed this as completed Oct 24, 2021
@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog Oct 24, 2021
@m2-community-project m2-community-project bot moved this from Done to Pull Request In Progress in High Priority Backlog Oct 24, 2021
@calin-ImDigital
Copy link
Author

Thanks everyone for a quick fix.

Also, 2.4.3 was released and I can't find the fix?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Cart & Checkout Component: GraphQL GraphQL Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
8 participants