Skip to content
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

Method $product->getUrlInStore() returning extremely long URLs, could be a bug #16273

Closed
adampmoss opened this issue Jun 20, 2018 · 7 comments
Closed
Assignees
Labels
bug report Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@adampmoss
Copy link
Contributor

adampmoss commented Jun 20, 2018

I feel like there may be a bug in the following file because the output of $product->getUrlInStore() is not what I'd expect. Query params related to the store are added to the URL in the following file:

$storeCode = $subject->getScope() ?: $this->storeManager->getStore()->getCode();

By setting an entire object ($subject->getScope()) as the $storeCoderather than just a string default it is causing a very messy looking URL.

Preconditions

  1. Have a Magento installation with more than 1 store
  2. Add store code to URLs in configuration is set to "no"
  3. Magento version 2.2.3

Steps to reproduce

Use the following code where a product model is loaded and where you can see the result:

<?= $product->getUrlInStore() ?>

Expected result

The URL produced for the product would look like:

https://www.domain.com/my-product.html?___store=default

Actual result

The URL produced is actually very long winded:

https://www.domain.com/my-product.html?___store%5B_data%5D%5Bstore_id%5D=1&___store%5B_data%5D%5Bcode%5D=default&___store%5B_data%5D%5Bwebsite_id%5D=1&___store%5B_data%5D%5Bgroup_id%5D=1&___store%5B_data%5D%5Bname%5D=UK+Mainland&___store%5B_data%5D%5Bsort_order%5D=0&___store%5B_data%5D%5Bis_active%5D=1&___store%5B_data%5D%5Bavailable_currency_codes%5D%5B0%5D=GBP&___store%5B_data%5D%5Bbase_currency%5D%5B_data%5D%5Bcurrency_code%5D=GBP&___store%5B_data%5D%5Bcurrent_currency%5D%5B_data%5D%5Bcurrency_code%5D=GBP
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 20, 2018
@vasilii-b
Copy link

vasilii-b commented Jun 21, 2018

This can be reproduced on Magento 2.3-develop as well.
And actually from steps to reproduce there is another bug: Having Add store code to URLs set to NO, still shows you the URL like https://www.domain.com/my-product.html?___store=default.

@vasilii-b vasilii-b added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Jun 21, 2018
@vasilii-b vasilii-b self-assigned this Jun 21, 2018
@vasilii-b
Copy link

vasilii-b commented Jun 21, 2018

According to the file /app/code/Magento/Store/Url/Plugin/RouteParamsResolver.php and its content, this issue is reproducible on Magento 2.2-develop and Magento 2.1-develop.

@vasilii-b vasilii-b added Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release labels Jun 21, 2018
vasilii-b pushed a commit to vasilii-b/magento2 that referenced this issue Jun 21, 2018
# Method $product->getUrlInStore() returning extremely long URLs, could be a bug
vasilii-b pushed a commit to vasilii-b/magento2 that referenced this issue Jun 21, 2018
# Method $product->getUrlInStore() returning extremely long URLs, could be a bug

(cherry picked from commit 7558ac0)
vasilii-b pushed a commit to vasilii-b/magento2 that referenced this issue Jun 21, 2018
# Method $product->getUrlInStore() returning extremely long URLs, could be a bug
vasilii-b pushed a commit to vasilii-b/magento2 that referenced this issue Jun 30, 2018
…store-wrong-link_mage22' into magento#16273-product-geturlinstore-wrong-link_mage22
vasilii-b pushed a commit to vasilii-b/magento2 that referenced this issue Jul 18, 2018
@magento-engcom-team
Copy link
Contributor

Hi @adampmoss. Thank you for your report.
The issue has been fixed in #16468 by @vasilii-b in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.6 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jul 29, 2018
magento-engcom-team added a commit that referenced this issue Jul 29, 2018
#16468

 - Merge Pull Request #16468 from vasilii-b/magento2:#16273-product-geturlinstore-wrong-link_mage22
 - Merged commits:
   1. 1115b3f
   2. 03afbc7
   3. 7e3c3fc
   4. 66ee827
   5. 846f605
   6. 65b735b
@sidolov
Copy link
Contributor

sidolov commented Aug 2, 2018

Hi @adampmoss. Thank you for your report.
The issue has been fixed in #17261 by @mage2pratik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Aug 2, 2018
magento-engcom-team added a commit that referenced this issue Aug 2, 2018
…of product model #17261

 - Merge Pull Request #17261 from mage2pratik/magento2:2.3-develop-PR-port-16468
 - Merged commits:
   1. d116454
   2. 3a39a16
   3. 16ae409
   4. 4dc6aba
@vasilii-b
Copy link

vasilii-b commented Aug 2, 2018

@magento-engcom-team , @sidolov hello!!!
there was already a PR created for 2.3-develop - #16309, earlier than one already merged #17261. 😱 what is going on, guys ? Should we check first if issue/PR already created ? 🤦‍♂️
that is totally unfair...

@sidolov
Copy link
Contributor

sidolov commented Aug 16, 2018

Hi @adampmoss. Thank you for your report.
The issue has been fixed in #16310 by @vasilii-b in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.16 release.

@sidolov sidolov added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Aug 16, 2018
magento-engcom-team added a commit that referenced this issue Aug 16, 2018
…product model #16310

 - Merge Pull Request #16310 from vasilii-b/magento2:#16273-product-geturlinstore-wrong-link_mage21
 - Merged commits:
   1. 2f8f469
   2. ecfbe24
   3. 7833f43
   4. 7c33686
   5. 726b6e9
magento-team pushed a commit that referenced this issue Sep 18, 2018
…ong-link_mage21' into 16273-product-geturlinstore-wrong-link_mage21

# Conflicts:
#	app/code/Magento/Store/Test/Unit/Url/Plugin/RouteParamsResolverTest.php
@arion-p
Copy link

arion-p commented Aug 29, 2019

The issue has been reintroduced in commit 22edbb9. The commit is supposed to revert "Customer related values are NULL for guests" ccba420 but it actually reverts this fix (at least partly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants