{"data":{"id":"magento2-39670","source":"github-pr","sourceRef":"magento/magento2#39670","title":"Product page gives error because of url rewrites","pr":{"number":39670,"url":"https://github.com/magento/magento2/pull/39670","author":"Himsoft","mergedAt":"2025-04-29T18:55:01Z","mergeCommit":"667c0adc67dabbc580511a3b4c4f0ef1ae1f4f5a","headCommit":"ca76908eab0142b2396f847068fe0a1c327728e4","baseRef":"2.4-develop","diffSha256":"6a69823360f89c9b79379e97311a1e9e02ff1b1e759e046a4666db80eee860cd"},"issues":[{"number":35371,"url":"https://github.com/magento/magento2/issues/35371","title":"Product page gives error because of url rewrites","labels":["Area: Catalog","Area: SEO / Metadata","Component: Catalog","Issue: Confirmed","Priority: P2","Progress: done","Reported on 2.4.1","Reported on 2.4.x"],"kind":"human"}],"fixedIn":"2.4.9","containingTags":["2.4.9"],"reportedOn":"2.4.1","codeMatch":{"2.4.6":"clean","2.4.6-p1":"clean","2.4.6-p2":"clean","2.4.6-p3":"clean","2.4.6-p4":"clean","2.4.6-p5":"clean","2.4.6-p6":"clean","2.4.6-p7":"clean","2.4.6-p8":"clean","2.4.6-p9":"clean","2.4.6-p10":"clean","2.4.6-p11":"clean","2.4.6-p12":"clean","2.4.6-p13":"clean","2.4.6-p14":"clean","2.4.6-p15":"clean","2.4.7":"clean","2.4.7-p1":"clean","2.4.7-p2":"clean","2.4.7-p3":"clean","2.4.7-p4":"clean","2.4.7-p5":"clean","2.4.7-p6":"clean","2.4.7-p7":"clean","2.4.7-p8":"clean","2.4.7-p9":"clean","2.4.7-p10":"clean","2.4.8":"clean","2.4.8-p1":"clean","2.4.8-p2":"clean","2.4.8-p3":"clean","2.4.8-p4":"clean","2.4.8-p5":"clean","2.4.9":"conflict"},"affectedVersions":["2.4.6","2.4.6-p1","2.4.6-p2","2.4.6-p3","2.4.6-p4","2.4.6-p5","2.4.6-p6","2.4.6-p7","2.4.6-p8","2.4.6-p9","2.4.6-p10","2.4.6-p11","2.4.6-p12","2.4.6-p13","2.4.6-p14","2.4.6-p15","2.4.7","2.4.7-p1","2.4.7-p2","2.4.7-p3","2.4.7-p4","2.4.7-p5","2.4.7-p6","2.4.7-p7","2.4.7-p8","2.4.7-p9","2.4.7-p10","2.4.8","2.4.8-p1","2.4.8-p2","2.4.8-p3","2.4.8-p4","2.4.8-p5"],"components":["magento/module-catalog-url-rewrite"],"files":[{"path":"app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php","change":"modified","package":"magento/module-catalog-url-rewrite"}],"stripped":{"tests":["app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Storage/DynamicStorageTest.php"],"docs":[],"outsideCode":[]},"linesChanged":8,"mergeBatched":false,"excluded":null,"sections":{"description":"1. There is 404 error (on 2.4.3 or newer version) or 500 error (on older version than 2.4.3).","stepsToReproduce":"1. Go to `Test Sub Category`.\n2. Click on product `Test`.","expectedResult":"1. The product page is loaded successfully.","actualResult":"1. There is 404 error (on 2.4.3 or newer version) or 500 error (on older version than 2.4.3).\n\nLooks like on line 173 in `\\Magento\\CatalogUrlRewrite\\Model\\Storage\\DynamicStorage` function `str_replace` should not be used. We fixed it on our installation by changing that line to this:\n```\n$categoryPath = substr($requestPath, 0, -1 * strlen('/' . $productUrl));\n```\n\n---\nPlease provide [Severity](https://devdocs.magento.com/guides/v2.4/contributor-guide/contributing.html#backlog) assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.\n\n- [ ] Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._\n- [ ] Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._\n- [x] Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._\n- [ ] Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._\n- [ ] Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._","source":"issue"},"signatures":[],"labels":{"area":["Catalog","SEO / Metadata"],"component":["Catalog"],"priority":"P2","severity":null,"reportedOn":["2.4.1","2.4.x"]},"categories":["Catalog/Product"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"acea5e280fb59e9766beca78343887eb4e2219aaab0f8d9d16a33935ce60f039","isBugfix":0.9801,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.9733,"feature":0.004,"refactor":0.011,"tests_only":0.0059,"docs_only":0.0027,"dependency":0.0031},"confidence":0.937},"scope":{"score":0.6316,"probabilities":{"0":0.4723,"1":0.4238,"2":0.1039},"confidence":0.1202},"risk":{"score":0.4379,"probabilities":{"0":0.6244,"1":0.3133,"2":0.0623},"confidence":0.2378},"area":{"choice":"catalog","probabilities":{"catalog":0.7544,"checkout":0.0123,"customer":0.01,"admin":0.0353,"graphql_api":0.0122,"framework":0.0518,"frontend":0.0375,"other":0.0865},"confidence":0.5226},"securityRelevant":0.0073,"reportedVersion":{"choice":"2.4.3","probabilities":{"2.4.0":0.0053,"2.4.0-p1":0.0031,"2.4.1":0.2513,"2.4.1-p1":0.0139,"2.4.2":0.007,"2.4.2-p1":0.0074,"2.4.2-p2":0.0122,"2.4.3":0.3474,"2.4.3-p1":0.0257,"2.4.3-p2":0.0222,"2.4.3-p3":0.0156,"2.4.4":0.0038,"2.4.4-p1":0.0039,"2.4.4-p10":0.0031,"2.4.4-p11":0.0042,"2.4.4-p12":0.0034,"2.4.4-p13":0.0038,"2.4.4-p14":0.0041,"2.4.4-p15":0.0037,"2.4.4-p16":0.0032,"2.4.4-p17":0.003,"2.4.4-p18":0.0033,"2.4.4-p2":0.0024,"2.4.4-p3":0.0023,"2.4.4-p4":0.0025,"2.4.4-p5":0.0028,"2.4.4-p6":0.0026,"2.4.4-p7":0.0027,"2.4.4-p8":0.0027,"2.4.4-p9":0.0024,"2.4.5":0.0033,"2.4.5-p1":0.0034,"2.4.5-p10":0.0027,"2.4.5-p11":0.0039,"2.4.5-p12":0.0037,"2.4.5-p13":0.0048,"2.4.5-p14":0.0036,"2.4.5-p15":0.0032,"2.4.5-p16":0.0025,"2.4.5-p17":0.0032,"2.4.5-p2":0.0021,"2.4.5-p3":0.0027,"2.4.5-p4":0.0031,"2.4.5-p5":0.0027,"2.4.5-p6":0.0031,"2.4.5-p7":0.0028,"2.4.5-p8":0.0025,"2.4.5-p9":0.002,"2.4.6":0.0041,"2.4.6-p1":0.0048,"2.4.6-p10":0.0052,"2.4.6-p11":0.0047,"2.4.6-p12":0.0046,"2.4.6-p13":0.0057,"2.4.6-p14":0.0045,"2.4.6-p15":0.0034,"2.4.6-p2":0.0027,"2.4.6-p3":0.0045,"2.4.6-p4":0.0046,"2.4.6-p5":0.004,"2.4.6-p6":0.0032,"2.4.6-p7":0.0035,"2.4.6-p8":0.0031,"2.4.6-p9":0.0023,"2.4.7":0.0025,"2.4.7-p1":0.0031,"2.4.7-p10":0.0029,"2.4.7-p2":0.0028,"2.4.7-p3":0.0046,"2.4.7-p4":0.005,"2.4.7-p5":0.0042,"2.4.7-p6":0.0057,"2.4.7-p7":0.0041,"2.4.7-p8":0.0037,"2.4.7-p9":0.0025,"2.4.8":0.0027,"2.4.8-p1":0.0033,"2.4.8-p2":0.0057,"2.4.8-p3":0.0064,"2.4.8-p4":0.0062,"2.4.8-p5":0.0054,"2.4.9":0.0058,"unspecified":0.0322},"confidence":0.1779},"backportWorthy":{"score":1.6818,"probabilities":{"0":0.0494,"1":0.2195,"2":0.7311},"confidence":0.3777}},"curated":{"title":"Fixes the 404 on a product page when the category path contains the URL key","description":"When a category with level above 2 has the product url key at the beginning of its url key, the product page gives a 404 error because str_replace replaces all parts of the category path equal to the product url key. The change in DynamicStorage removes only the product url key at the end of the request path.","categories":["Catalog/Product"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":{"2.4.8-p5":{"before":"fail","after":"pass","adapted":false,"runAt":"2026-10-06T09:20:08.530Z","releaseCommit":"870a22c63d9d9b68fa3297962e2d5d5841115814","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:20:08.530Z"}}},"2.4.7-p10":{"before":"fail","after":"pass","adapted":false,"runAt":"2026-10-06T09:29:29.089Z","releaseCommit":"72561bf80652f57cc642a03e2c9a51d74a285b14","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:29:29.089Z"}}}}},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-39670 details"}