Skip to content

Product page gives error because of url rewrites #35371

Closed
@edas11

Description

@edas11

Preconditions (*)

  1. Magento 2.4.1, 2.4.3 (this problem may exist from 2.3.3).
  2. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Product URL Suffix is empty.
  3. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Category URL Suffix is empty.
  4. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Use Categories Path For Product URLs is Yes.
  5. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Generate "category/product" URL Rewrites is No.
  6. There is a category Test Category created under root category and Test Sub Category created under Test Category. There is a product Test and it is assigned to Test Sub Category. This is to make category url path have the product url path in it preceded by a forward slash (/). In this example the product url path is "test" and Test Sub Category url path is "test-category/test-sub-category"

Steps to reproduce (*)

  1. Go to Test Sub Category.
  2. Click on product Test.

Expected result (*)

  1. The product page is loaded successfully.

Actual result (*)

  1. There is 404 error (on 2.4.3 or newer version) or 500 error (on older version than 2.4.3).

Looks 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:

$categoryPath = substr($requestPath, 0, -1 * strlen('/' . $productUrl));

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: CatalogArea: SEOComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.4.1Indicates original Magento version for the Issue report.Reported on 2.4.xIndicates original Magento version for the Issue report.

Type

No type

Projects

Status

Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions