-
Notifications
You must be signed in to change notification settings - Fork 9.4k
issue/26384 Fix store switcher when using different base url on stores #26548
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
issue/26384 Fix store switcher when using different base url on stores #26548
Conversation
Hi @TobiasCodeNull. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. Please see my comment. And could you please cover your change by Automation Test? Thank you !
@@ -53,12 +60,14 @@ public function __construct( | |||
StoreResolverInterface $storeResolver, | |||
\Magento\Framework\Session\Generic $session, | |||
\Magento\Framework\Session\SidResolverInterface $sidResolver, | |||
HashGenerator $hashGenerator | |||
HashGenerator $hashGenerator, | |||
StoreManagerInterface $storeManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change it to StoreManagerInterface $storeManager = null
for backward compatible
https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/
) { | ||
parent::__construct($context); | ||
$this->storeRepository = $storeRepository; | ||
$this->storeResolver = $storeResolver; | ||
$this->hashGenerator = $hashGenerator; | ||
$this->storeManager = $storeManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
for backward compatible
https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/
Simple test made which goes through the controller and make sure that the StoreManager change to the correct store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Please add use ...
to your code and add some const
. Thanks.
*/ | ||
protected function setUp() | ||
{ | ||
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)->getMock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Magento\Store\Model\StoreManagerInterface;
in all similar class and use the Alias.
*/ | ||
public function testExecute() | ||
{ | ||
$storeToSwitchToCode = 'sv2'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the const const STUB_STORE_TO_SWITCH_TO_CODE = 'sv2';
and const STUB_DEFAULT_STORE_VIEW = 'default';
app/code/Magento/Store/Test/Unit/Controller/Store/RedirectTest.php
Outdated
Show resolved
Hide resolved
Cleaned up code and added Const values. |
Hi @TobiasCodeNull. Please resolve the confict code. And please use the alias in the DocBlock also. |
Hi, @edenduong I'll take care of this. |
# Conflicts: # app/code/Magento/Store/Test/Unit/Controller/Store/RedirectTest.php
…k\MockObject\MockObject in DocBlocks
I'll leave this to @engcom-Charlie then |
Hi @edenduong, thank you for the review. |
@TobiasCodeNull thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository. |
✔️ QA passed |
Hi @TobiasCodeNull, thank you for your contribution! |
For Magento versions 2.3.0 - 2.3.5 patch is available in Magento Quality Patches package (MQP) MQP Installation Applying a Patch Patch Details |
Description (*)
When a user switches between stores using the store switcher the request fails if the target store has a different base url than the current. This pull request changes the redirect controller to make the switch request using the targeted store' url instead so the switch is successful.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Result without fix: You end up on the start page, without switched store and not the category on which you were on.
Result with fix: Store is switched and you stay in the same page you were on
Questions or comments
No automated tests has been created for this pull request
Contribution checklist (*)