This page has moved to Adobe Experience League and will be redirected soon.
MDVA-37234: Adding item to cart multiple times creates duplicate line item
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 QPT landing 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:
-
Create a simple product with SKU = simple1.
-
Create a customer.
-
Generate a customer token for making GraphQL request.
mutation {
generateCustomerToken(
email: "customer email"
password: "customer password"
)
{
token
}
}
-
Use the token mentioned in step 3 to create an empty cart for the customer.
mutation{
createEmptyCart
}
-
Create a script to make two addSimpleProductsToCart
requests running in parallel. For example:
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
-
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.