{"data":{"id":"magento2-40248","source":"github-pr","sourceRef":"magento/magento2#40248","title":"Call RemoveItem on cart instead of ItemRepository","pr":{"number":40248,"url":"https://github.com/magento/magento2/pull/40248","author":"indykoning","mergedAt":"2026-03-05T14:41:22Z","mergeCommit":"601080409b09135ce6c2f5383ad38b5f19261091","headCommit":"9d9149b0d3e9859037dbdd8cef433422128efdc9","baseRef":"2.4-develop","diffSha256":"e0f57904ceb24cb2b2b5c354ee57a4a2bb69e9b696d68047db58bf4c2f56de3a"},"issues":[{"number":40255,"url":"https://github.com/magento/magento2/issues/40255","title":"[Issue] Call RemoveItem on cart instead of ItemRepository","labels":["Area: Cart & Checkout","Component: GraphQL","Issue: Confirmed","Priority: P2","Progress: PR Created","Progress: done","Reported on 2.4.x","Reproduced on 2.4.x"],"kind":"pr-derived"}],"fixedIn":"2.4.9","containingTags":["2.4.9"],"reportedOn":null,"codeMatch":{"2.4.6":"conflict","2.4.6-p1":"conflict","2.4.6-p2":"conflict","2.4.6-p3":"conflict","2.4.6-p4":"conflict","2.4.6-p5":"conflict","2.4.6-p6":"conflict","2.4.6-p7":"conflict","2.4.6-p8":"conflict","2.4.6-p9":"conflict","2.4.6-p10":"conflict","2.4.6-p11":"conflict","2.4.6-p12":"conflict","2.4.6-p13":"conflict","2.4.6-p14":"conflict","2.4.6-p15":"conflict","2.4.7":"conflict","2.4.7-p1":"conflict","2.4.7-p2":"conflict","2.4.7-p3":"conflict","2.4.7-p4":"conflict","2.4.7-p5":"conflict","2.4.7-p6":"conflict","2.4.7-p7":"conflict","2.4.7-p8":"conflict","2.4.7-p9":"conflict","2.4.7-p10":"conflict","2.4.8":"conflict","2.4.8-p1":"conflict","2.4.8-p2":"conflict","2.4.8-p3":"conflict","2.4.8-p4":"conflict","2.4.8-p5":"conflict","2.4.9":"conflict"},"affectedVersions":[],"components":["magento/module-quote-graph-ql"],"files":[{"path":"app/code/Magento/QuoteGraphQl/Model/Cart/MergeCarts/CartQuantityValidator.php","change":"modified","package":"magento/module-quote-graph-ql"},{"path":"app/code/Magento/QuoteGraphQl/Model/CartItem/DataProvider/UpdateCartItems.php","change":"modified","package":"magento/module-quote-graph-ql"},{"path":"app/code/Magento/QuoteGraphQl/Model/Resolver/RemoveItemFromCart.php","change":"modified","package":"magento/module-quote-graph-ql"}],"stripped":{"tests":["dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/RemoveItemSavesCartTest.php"],"docs":[],"outsideCode":[]},"linesChanged":48,"mergeBatched":false,"excluded":null,"sections":{"description":"This PR replaces the deleteById calls on the CartItemRepository with removeItem on the cart instance.\nThis makes sure expected observers are triggered and the item is actually updated on the cart object as well, instead of in the database only.","stepsToReproduce":"1. Add multiple products to the cart\n2. remove the products with the following query\n```\nmutation updateCart($input: UpdateCartItemsInput) {\n  updateCartItems(input: $input) {\n    cart {\n      items {\n        uid\n      }\n    }\n  }\n}\n\n{\n  \"input\": {\n    \"cart_id\": \"xxxx\",\n    \"cart_items\": [\n      {\n        \"cart_item_id\": \"xx\",\n        \"quantity\": 0\n      },\n      {\n        \"cart_item_id\": \"xx\",\n        \"quantity\": 0\n      },\n      {\n        \"cart_item_id\": \"xx\",\n        \"quantity\": 0\n      },\n      {\n        \"cart_item_id\": \"xx\",\n        \"quantity\": 0\n      },\n      {\n        \"cart_item_id\": \"xx\",\n        \"quantity\": 0\n      }\n    ]\n  }\n}\n```\n3. Observe how items still appear to be in the cart until you manually request the cart again.\n4. Repeat these steps after applying this PR\n5. Observe how all selected items have immediately disappeared from the response.","expectedResult":null,"actualResult":null,"source":"pr"},"signatures":[],"labels":{"area":["Cart & Checkout"],"component":["GraphQL"],"priority":"P2","severity":null,"reportedOn":["2.4.x"]},"categories":["GraphQL","Shopping Cart"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"3f778eff7689249a9d1ef97dd6b7b659cd47f3ab946198014749f58ba101b1ab","isBugfix":0.9398,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.9538,"feature":0.0046,"refactor":0.0305,"tests_only":0.0065,"docs_only":0.0021,"dependency":0.0025},"confidence":0.8929},"scope":{"score":1.0556,"probabilities":{"0":0.2227,"1":0.499,"2":0.2783},"confidence":0.0641},"risk":{"score":1.0596,"probabilities":{"0":0.3297,"1":0.281,"2":0.3893},"confidence":0.0088},"area":{"choice":"graphql_api","probabilities":{"catalog":0.0028,"checkout":0.3616,"customer":0.0029,"admin":0.0033,"graphql_api":0.6174,"framework":0.0047,"frontend":0.0039,"other":0.0034},"confidence":0.4423},"securityRelevant":0.0067,"reportedVersion":{"choice":"unspecified","probabilities":{"2.4.0":0.0042,"2.4.0-p1":0.0037,"2.4.1":0.0042,"2.4.1-p1":0.003,"2.4.2":0.0066,"2.4.2-p1":0.0053,"2.4.2-p2":0.0079,"2.4.3":0.0116,"2.4.3-p1":0.0089,"2.4.3-p2":0.0117,"2.4.3-p3":0.0078,"2.4.4":0.0144,"2.4.4-p1":0.009,"2.4.4-p10":0.0067,"2.4.4-p11":0.0083,"2.4.4-p12":0.0068,"2.4.4-p13":0.0065,"2.4.4-p14":0.0082,"2.4.4-p15":0.0057,"2.4.4-p16":0.0063,"2.4.4-p17":0.0056,"2.4.4-p18":0.0049,"2.4.4-p2":0.0028,"2.4.4-p3":0.0032,"2.4.4-p4":0.0035,"2.4.4-p5":0.0041,"2.4.4-p6":0.0043,"2.4.4-p7":0.0041,"2.4.4-p8":0.0045,"2.4.4-p9":0.0041,"2.4.5":0.0177,"2.4.5-p1":0.0109,"2.4.5-p10":0.0074,"2.4.5-p11":0.0116,"2.4.5-p12":0.0086,"2.4.5-p13":0.0076,"2.4.5-p14":0.0076,"2.4.5-p15":0.0069,"2.4.5-p16":0.0064,"2.4.5-p17":0.0067,"2.4.5-p2":0.0033,"2.4.5-p3":0.0053,"2.4.5-p4":0.0053,"2.4.5-p5":0.0056,"2.4.5-p6":0.0054,"2.4.5-p7":0.0053,"2.4.5-p8":0.0049,"2.4.5-p9":0.004,"2.4.6":0.045,"2.4.6-p1":0.0178,"2.4.6-p10":0.0121,"2.4.6-p11":0.0118,"2.4.6-p12":0.0105,"2.4.6-p13":0.0102,"2.4.6-p14":0.0103,"2.4.6-p15":0.0083,"2.4.6-p2":0.0044,"2.4.6-p3":0.0072,"2.4.6-p4":0.0097,"2.4.6-p5":0.0067,"2.4.6-p6":0.0076,"2.4.6-p7":0.0072,"2.4.6-p8":0.0055,"2.4.6-p9":0.0047,"2.4.7":0.0187,"2.4.7-p1":0.013,"2.4.7-p10":0.0097,"2.4.7-p2":0.0075,"2.4.7-p3":0.011,"2.4.7-p4":0.016,"2.4.7-p5":0.0117,"2.4.7-p6":0.0124,"2.4.7-p7":0.0115,"2.4.7-p8":0.0091,"2.4.7-p9":0.0056,"2.4.8":0.0171,"2.4.8-p1":0.015,"2.4.8-p2":0.0167,"2.4.8-p3":0.0156,"2.4.8-p4":0.0156,"2.4.8-p5":0.0133,"2.4.9":0.017,"unspecified":0.2661},"confidence":0.0688},"backportWorthy":{"score":1.6029,"probabilities":{"0":0.0794,"1":0.2383,"2":0.6823},"confidence":0.2929}},"curated":{"title":"Fixes GraphQL updateCartItems response still listing removed cart items","description":"If you mass remove items using updateCartItems, the items still appear to be in the cart in the response until you manually request the cart again. UpdateCartItems, the RemoveItemFromCart resolver and the MergeCarts CartQuantityValidator now call removeItem on the cart instead of deleteById on the CartItemRepository, and RemoveItemFromCart also calls save on the cart repository.","categories":["GraphQL","Shopping Cart"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":null},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-40248 details"}