Skip to content

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

Closed
@adampmoss

Description

@adampmoss

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

Metadata

Metadata

Assignees

Labels

Fixed in 2.1.xThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passedReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions