-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix URL rewrite match search when switching store #20093
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
Fix URL rewrite match search when switching store #20093
Conversation
Notable changes: - Uses target path to match URL rewrites between stores. Request path (used previously) can be different between stores. - Changes the target URL if matching URL rewrite is found. Previously it just redirected to the homepage in case the rewrite wasn't found, and did nothing if found.
Hi @aapokiiso. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @davidverholen. Thank you for your request. I'm working on Magento instance for you |
the test seems to fail since url rewriting (index.php to /) is not enabled in the integration test suite. @aapokiiso can you update the respective test case and see if the build succeeds please |
"/index.php" -> "/" rewrite is not configured on test servers, so we need to include "index.php" in test URLs.
@aapokiiso thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository. |
Thanks @aapokiiso Not sure which one of these two is the better one... |
@hostep Nice find, they seem to achieve the same thing with some minor differences. My PR selects the first matching URL rewrite, whereas #19798 selects the last one. As I understand, normally there wouldn't be multiple URL rewrites for the same target path + store combination, so this shouldn't matter. The other difference is the target URL generation based on the rewrite request path. My PR uses |
@aapokiiso the test is failing again, now having http://localhost/index.php/page-c-on-2nd-store/ as the redirected url. |
Magento\Store\Model\Store::getUrl expects the $route parameter to be a module/controller/action combination, not a free-form URL path like in this case.
…pokiiso/magento2 into url-rewrite-switch-store-correct-path
@davidverholen As I understand, the code is performing correctly but the test needs to be fixed to expect |
@aapokiiso I think you are right and the test was basically wrong succeeding before since it should have expected the url key form the second store |
Hi @aapokiiso, |
Hi @aapokiiso, thank you for your contribution! |
@davidverholen Ok, thanks for the info! By the way, the "Contribution Survey" link above is broken. |
@aapokiiso thanks for the hint, I'll try find someone where I can forward this to ;) |
@aapokiiso did you login on the page via github? Just wondering if it is maybe only available for the PR author |
Hi @aapokiiso , @davidverholen survey link was fixed, you may try once again. I'm sorry for the inconvenience |
@sidolov: sorry to intrude in this thread, I also recently got such a link in an accepted PR, and now it works indeed. But it asks me to login and then says I have to give Magento read and write access to all my public repo's. I'm not really comfortable with this, is there somehow a way to reduce the amount of permissions we must give you to login to https://opensource.magento.com/ ? Exact permissions it asks are:
|
Description (*)
When "Use Store Code in URLs" is enabled, Magento 2 currently redirects to the homepage if changing the store from a product, category or CMS page. So basically any page which uses URL rewrites. There has been some work done on this by Magento (see issue #2786), but there's no definitive solution yet. This PR aims to fix the issues with the following changes:
stores. Request path (used previously) can be
different between stores.
URL rewrite is found. Previously it just
redirected to the homepage in case the rewrite
wasn't found, and did nothing if found.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)