Skip to content

magento/magento2#35371: Product page gives error because of url rewrites #39670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Himsoft
Copy link
Contributor

@Himsoft Himsoft commented Feb 28, 2025

Description (*)

In situation when category with level > 2 have product url key at the beginning of its url key, str_replace(), used in \Magento\CatalogUrlRewrite\Model\Storage\DynamicStorage::findProductRewriteByRequestPath, replaces all parts of the category path equal to the product url key.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Product page gives error because of url rewrites #35371

Manual testing scenarios (*)

  1. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Product URL Suffix is empty.
  2. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Category URL Suffix is empty.
  3. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Use Categories Path For Product URLs is Yes.
  4. Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Generate "category/product" URL Rewrites is No.
  5. Create new category with name Test Category under root category (Catalog - Categories)
  6. Create sub category with name Test Sub Category under new category and save (Catalog - Categories)
  7. Create Product with name Test and assigned only new sub category and save
  8. Go to Test Sub Category.
  9. Click on product Test.

Before fix:
There is 404 error.

After fix:
The product page is loaded successfully.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Copy link

m2-assistant bot commented Feb 28, 2025

Hi @Himsoft. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@m2-github-services m2-github-services added Partner: Perspective partners-contribution Pull Request is created by Magento Partner labels Feb 28, 2025
@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

@magento run all tests

@engcom-Bravo engcom-Bravo added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Feb 28, 2025
@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

@magento run all tests

@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

@magento run all tests

@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

@magento run Functional Tests B2B

1 similar comment
@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

@magento run Functional Tests B2B

@Himsoft
Copy link
Contributor Author

Himsoft commented Feb 28, 2025

The failed tests are not related to fixes, they look like false positives, please pay attention to this during the review.

@Priyakshic Priyakshic added the Project: Community Picked PRs upvoted by the community label Mar 13, 2025
@Priyakshic Priyakshic moved this to Pending Review in Community Dashboard Mar 13, 2025
@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel engcom-Hotel moved this from Pending Review to Review in Progress in Community Dashboard Mar 27, 2025
Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Himsoft,

Thank you for your contribution!

Please make the changes as per the below review comment, also add appropriate test data in its file to satisfy the PR changes.

Thanks

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2025 Adobe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be 2019, as the file has been created in this year only.

@engcom-Hotel engcom-Hotel moved this from Review in Progress to Changes Requested in Community Dashboard Mar 27, 2025
@Himsoft
Copy link
Contributor Author

Himsoft commented Mar 27, 2025

@magento run all tests

@engcom-Dash engcom-Dash self-assigned this Apr 7, 2025
@engcom-Dash
Copy link
Contributor

@Himsoft Thank you for the contribution!
Are you working on the test data changes mentioned in the review-comment to satisfy the PR changes ?

@engcom-Dash
Copy link
Contributor

@magento run all tests

@Himsoft
Copy link
Contributor Author

Himsoft commented Apr 8, 2025

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

engcom-Dash commented Apr 11, 2025

@engcom-Hotel The test data changes has been added by @Himsoft. Also, I have fixed some of the failing static test cases. Hence Moving this PR to Pending Review.

@engcom-Dash engcom-Dash moved this from Changes Requested to Pending Review in Community Dashboard Apr 11, 2025
@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE

@ct-prd-projects-boards-automation ct-prd-projects-boards-automation bot moved this from Pending Review to Ready for Testing in Community Dashboard Apr 14, 2025
@engcom-Bravo engcom-Bravo moved this from Ready for Testing to Testing in Progress in Community Dashboard Apr 15, 2025
@engcom-Bravo
Copy link
Contributor

Hi @Himsoft,

Thanks for the collaboration & contribution!

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop

Steps to reproduce

  • Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Product URL Suffix is empty.
  • Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Category URL Suffix is empty.
  • Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Use Categories Path For Product URLs is Yes.
  • Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> Generate "category/product" URL Rewrites is No.
  • Create new category with name Test Category under root category (Catalog - Categories)
  • Create sub category with name Test Sub Category under new category and save (Catalog - Categories)
  • Create Product with name Test and assigned only new sub category and save
  • Go to Test Sub Category.
  • Click on product Test.

Before: ✖️ 

Screenshot 2025-04-15 at 1 44 07 pm

After: ✔️

Screenshot 2025-04-15 at 1 54 22 pm

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks.

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Extended testing (optional) in Community Dashboard Apr 15, 2025
@engcom-Charlie engcom-Charlie self-assigned this Apr 16, 2025
@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE

@engcom-Charlie
Copy link
Contributor

@engcom-Charlie engcom-Charlie moved this from Extended testing (optional) to Merge in Progress in Community Dashboard Apr 21, 2025
@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 667c0ad into magento:2.4-develop Apr 29, 2025
11 of 12 checks passed
@ct-prd-projects-boards-automation ct-prd-projects-boards-automation bot moved this from Merge in Progress to Recently Merged in Community Dashboard Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Perspective partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review Progress: ready for testing Project: Community Picked PRs upvoted by the community
Projects
Status: Recently Merged
Development

Successfully merging this pull request may close these issues.

Product page gives error because of url rewrites
8 participants