MDVA-37234: Adding item to cart multiple times creates duplicate line item

The MDVA-37234 patch fixes the issue where adding an item to the cart multiple times (parallel request) for the same SKU creates a duplicate line item for the same cart ID. This patch is available when the Quality Patches Tool (QPT) 1.1.3 is installed. The patch ID is MDVA-37234. Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.4.

Affected products and versions

The patch is created for Adobe Commerce version:

Adobe Commerce (all deployment methods) 2.3.6, 2.4.1, and 2.4.2

Compatible with Adobe Commerce versions:

Adobe Commerce (all deployment methods) 2.3.5 - 2.3.7-p1 and 2.4.1 - 2.4.2-p1

NOTE
The patch might become applicable to other versions with new Quality Patches Tool releases. To check if the patch is compatible with your Adobe Commerce version, update the magento/quality-patches package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.

Issue

Adding an item to the cart multiple times (parallel request) for the same SKU creates a duplicate line item for the same cart ID.

Steps to reproduce:

  1. Create a simple product with SKU = simple1.

  2. Create a customer.

  3. Generate a customer token for making GraphQL request.

    code language-graphql
    
     mutation {
         generateCustomerToken(
             email: "customer email"
             password: "customer password"
         )
         {
             token
         }
     }
    
    
  4. Use the token mentioned in step 3 to create an empty cart for the customer.

    code language-graphql
    
     mutation{
      createEmptyCart
     }
    
    
  5. Create a script to make two addSimpleProductsToCart requests running in parallel. For example:

    code language-#!/bin/bash
    
     curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MywiaWF0IjoxNjIzOTUyNjcwLCJleHAiOjE2MjM5NTYyNzB9.-fh7ysqiQTAacdB3MVvaXzFE9AmKyfF8TsVmICLJoWI" -d '{"query" : "mutation { addSimpleProductsToCart( input: { cart_id: \"S8dCF7uan1POMy0qY0Hup7tEv1AhFGdY\" cart_items: [ { data: { quantity: 2 sku: \"simple1\" } } ] } ) { cart { items { id product { name sku } quantity } } } }"}' http://magento2.3.local/graphql &
     curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MywiaWF0IjoxNjIzOTUyNjcwLCJleHAiOjE2MjM5NTYyNzB9.-fh7ysqiQTAacdB3MVvaXzFE9AmKyfF8TsVmICLJoWI" -d '{"query" : "mutation { addSimpleProductsToCart( input: { cart_id: \"S8dCF7uan1POMy0qY0Hup7tEv1AhFGdY\" cart_items: [ { data: { quantity: 1 sku: \"simple1\" } } ] } ) { cart { items { id product { name sku } quantity } } } }"}' http://magento2.3.local/graphql
    
    
  6. Run the script.

Expected results:

Only one product line with a total quantity (three in this case) is created in the Shopping Cart.

Actual results:

Two separate lines for the same product are created in the Shopping Cart.

Apply the patch

To apply individual patches, use the following links depending on your deployment type:

To learn more about quality patches for Adobe Commerce, refer to:

For info about other patches available in QPT, refer to the Patches available in QPT section.

recommendation-more-help
8bd06ef0-b3d5-4137-b74e-d7b00485808a