UPSTREAM FIX

magento2-40203: Duplicate item error on the product compare page without a list

Community fix magento2-40203 merged into magento/magento2 on 2026-02-10, released in 2.4.9.

Fixes the duplicate item error on the product compare page without a list edited

Pull request title
Fix error visiting compare page without items
Pull request
magento/magento2#40203
Issues
#40205 pr-derived
Author
@indykoning
Merged
2026-02-10
Fixed in
2.4.9
Reported on
—
Categories
Catalog/Product
Components
magento/module-catalog

Labels

Area
Catalog
Component
Catalog
Priority
P2
Severity
—
Reported on (labels)
2.4.x

Issue

Title and steps come from the upstream issue and pull request.

Description

Going incognito and visiting /catalog/product_compare/index/ will cause an
Item (Magento\Catalog\Model\Product\Interceptor) with the same ID "xxx" already exists.

Steps to reproduce

1. Ensure your catalog_compare_items somewhat matches the example above (duplicate product id's on different lists)
2. Visit the /catalog/product_compare/index/ route in incognito, so no visitor id, customer id, or list id is assigned to you
3. See the error that occurs.

Taken from the upstream pull request.

Error signatures

Code match per tag

Each tag was checked with git apply --check against that tag's files. A clean match means the change applies; it is not a test result. Tags that already contain the fix are marked.

LineCode match per tagTests
2.4.6
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.6: no test data 2.4.6-p1: no test data 2.4.6-p2: no test data 2.4.6-p3: no test data 2.4.6-p4: no test data 2.4.6-p5: no test data 2.4.6-p6: no test data 2.4.6-p7: no test data 2.4.6-p8: no test data 2.4.6-p9: no test data 2.4.6-p10: no test data 2.4.6-p11: no test data 2.4.6-p12: no test data 2.4.6-p13: no test data 2.4.6-p14: no test data 2.4.6-p15: no test data
2.4.7
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.7: no test data 2.4.7-p1: no test data 2.4.7-p2: no test data 2.4.7-p3: no test data 2.4.7-p4: no test data 2.4.7-p5: no test data 2.4.7-p6: no test data 2.4.7-p7: no test data 2.4.7-p8: no test data 2.4.7-p9: no test data 2.4.7-p10: no test data
2.4.8
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.8: no test data 2.4.8-p1: no test data 2.4.8-p2: no test data 2.4.8-p3: no test data 2.4.8-p4: no test data 2.4.8-p5: no test data
2.4.9
2.4.9 conflictcontains the fix
2.4.9: no test data

Triage

Model @cf/cloudflare/clef. Probability this is a bug fix: 98.1%. Probability it is security relevant: 3.0%.

Show the model's answers and probabilities
QuestionAnswerProbabilitiesConfidence
Change kindbugfixbugfix 97.5%, refactor 0.9%, tests_only 0.7%, feature 0.5%, dependency 0.3%, docs_only 0.2%94.1%
Areacatalogcatalog 85.7%, graphql_api 3.0%, frontend 3.0%70.0%
Reported versionunspecifiedunspecified 30.2%, 2.4.6 2.6%, 2.4.7 2.4%8.8%
Scope0.55 of 20 54.4%, 1 36.4%, 2 9.1%15.6%
Risk0.32 of 20 73.0%, 1 22.3%, 2 4.7%37.8%
Worth backporting1.76 of 22 80.2%, 1 15.3%, 0 4.5%50.3%

Download

For cweagans/composer-patches, choose a version below and download the bundle. Copy its magento2-40203/ folder into patches/composer/, merge composer.patches.json into composer.json, then run composer install. Test files are always removed; paths are relative to each package root, using the default -p1 level.

No checked release lacks this fix with a clean code match, so no bundle is offered.

Bundle README (what the ZIP ships)
# magento2-40203

Community fix merged upstream into magento/magento2, adapted by magento.watch.
This is not a patch published by Adobe.

Pull request: https://github.com/magento/magento2/pull/40203
Issue: https://github.com/magento/magento2/issues/40205
Author: @indykoning
Source commit: b5daa7f58fabf8cbd8a491514b10e9abed17febb
Modifications: test files and documentation removed, paths rewritten relative to each Composer package.
Licence: OSL-3.0 / AFL-3.0, as the original Magento Open Source code.
Maintainer: Łukasz Bajsarowicz (@lbajsarowicz)

Licence: Magento Open Source code under OSL-3.0 and AFL-3.0. The bundle carries the original author, source commit and the list of modifications.

Sources

Łukasz Bajsarowicz
Built by

Łukasz Bajsarowicz, e-commerce architect

Magento and Adobe Commerce architecture, upgrades, performance and audits for merchants and agencies since 2015; magento.watch is the tooling I use on those projects.

Open source, maintained on weekends.