Skip to content

[GraphQL] - addProductsToCart mutation doesn't work as expect with a given parent_sku #39873

Open
@Dnd-Mafer

Description

@Dnd-Mafer

Preconditions and environment

  • Magento 2.4.8
  • Native M2 with Sample data installed

Steps to reproduce

  • create an empty cart
mutation {
  createGuestCart {
      cart {
          id
      }
  }
}
mutation {
  addProductsToCart(
    cartId: "LclKxxxxxxxxxxxxxxW"
    cartItems: [
      {
        quantity: 1
        parent_sku: "WSH12"
        sku: "WSH12-28-Green"
      }
    ]
  ) {
    cart {
      itemsV2 {
        items {
          id
          product {
            name
            sku
          }
          quantity
        }
        total_count
        page_info {
          page_size
          current_page
          total_pages
        }
      }
    }
    user_errors {
      code
      message
    }
  }
}

Expected result

{
  "data": {
    "addProductsToCart": {
      "cart": {
        "itemsV2": {
          "items": [
            {
              "id": "24",
              "product": {
                "name": "Erika Running Short",
                "sku": "WSH12"
              },
              "quantity": 1
            },
            {
              "id": "26",
              "product": {
                "name": "Erika Running Short-28-Green",
                "sku": "WSH12-28-Green"
              },
              "quantity": 1
            }
          ],
          "total_count": 2,
          "page_info": {
            "page_size": 20,
            "current_page": 1,
            "total_pages": 1
          }
        }
      },
      "user_errors": []
    }
  }
}

Actual result

{
  "data": {
    "addProductsToCart": {
      "cart": {
        "itemsV2": {
          "items": [
            {
              "id": "18",
              "product": {
                "name": "Erika Running Short-28-Green",
                "sku": "WSH12-28-Green"
              },
              "quantity": 1
            }
          ],
          "total_count": 1,
          "page_info": {
            "page_size": 20,
            "current_page": 1,
            "total_pages": 1
          }
        }
      },
      "user_errors": []
    }
  }
}

Additional information

When we use the other way it works as expected.

The main problem is the cart doesn't contain the configurable product which leads to issues.

Release note

[GraphQL] - fix addProductsToCart when specifying parent_sku to work as expected

Triage and priority

  • 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”.

Metadata

Metadata

Labels

Area: Cart & CheckoutComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.8Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions