-
Notifications
You must be signed in to change notification settings - Fork 9.4k
MC-38592 Fixed load regions for scope #30755
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
Conversation
…directory data helper
…ons of different scopes
Hi @bogutskyy. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
@magento run all tests |
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 @bogutskyy, thanks for contributing! Can you have a look at my comments below? Also, can you have a look at the failed tests and fix them?
Thank you!
$scopeKey = $scope['value'] ? '_' . implode('_', $scope) : ''; | ||
$cacheKey = 'DIRECTORY_REGIONS_JSON' . $scopeKey; |
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.
Can you give more details on why this change here is relevant?
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.
Doesn't make sense to have string _STORE in cache key template, because $scope['type']
already contains scope type. In result currently cache key for store takes value DIRECTORY_REGIONS_JSON_STORE_STORE_1.
@@ -406,14 +406,21 @@ public function getWeightUnit() | |||
* Get current scope from request | |||
* | |||
* @return array | |||
* @throws \Magento\Framework\Exception\NoSuchEntityException | |||
*/ | |||
private function getCurrentScope(): array |
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.
This method has as a goal (as described on the PHP doc block) to get the current scope from the request, I'm not sure that such change makes sense, maybe we should look at the problem from the request perspective?
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.
Method getCurrentScope has been added in commit 2b4cfab, ticket MC-33168, and this change produced issue #30577. tbh, my change looks like quick fix. I am not sure that method getCurrentScope should be here. In this class we have store resolver. I think make sense to move logic of current scope determination into store resolver. But I don't know what issue MC-33168 was about, and afraid to broke something, what has been fixed previously. Therefore I decided change default value in method getCurrentScope. If somebody can explain me issue of MC-33168, then I'll be able to move on.
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.
I agree that getCurrentScope
probably shouldn't be on this helper, but by adding that condition it makes the function ambiguous. My proposal would be to look at the solution from the Create Order perspective, see from which request this function is being called, and make sure we have the correct scope on the request, it should be also a quick fix, what do you think?
@magento run all tests |
Hi @bogutskyy, sorry for the delay on this. Please follow some information from MC-33168:
|
@@ -406,14 +406,21 @@ public function getWeightUnit() | |||
* Get current scope from request | |||
* | |||
* @return array | |||
* @throws \Magento\Framework\Exception\NoSuchEntityException | |||
*/ | |||
private function getCurrentScope(): array |
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.
I agree that getCurrentScope
probably shouldn't be on this helper, but by adding that condition it makes the function ambiguous. My proposal would be to look at the solution from the Create Order perspective, see from which request this function is being called, and make sure we have the correct scope on the request, it should be also a quick fix, what do you think?
Hello @bogutskyy, could you please look at #30755 (comment)? |
Hello @bogutskyy, I'll try to continue with your PR. |
@engcom-Charlie sure. Unfortunately, I don't have time to finish PR in the coming weeks Let me know if you need anything from me. |
@magento run all tests |
Hi @gabrieldagama, thank you for the review.
|
✔️ QA passed |
Note: Functional Tests B2B are failed |
Hi @bogutskyy, thank you for your contribution! |
Hi Guys, I am running Magento 2.4.2. I Just migrated from 1.9.3. Alot of my orders are declining due to this issue. Is there a way I can fix this on my website quick? Regards, |
Description (*)
Currently, if different scopes have different allowed countries, then can be issue on address forms. One of issue described in #30577: new order can not be created from admin. Another issue, which I found, on customer address edit page, when for US doesn't appear states dropdown.

I fixed regions loading depending on current scope.
Related Pull Requests
No related PRs
Fixed Issues (if relevant)
Manual testing scenarios (*)
See #30577
Questions or comments
Looks like directory helper has been broken after fix in ticket MC-33168. Unfortunately I don't know what the problem was in MC-33168, but after code changes investigation I guess it was issue, when scope present in request params. Not sure the fix of MC-33168 was correct, maybe logic of current scope determination should be moved from app/code/Magento/Directory/Helper/Data.php to app/code/Magento/Store/Model/StoreResolver.php.
Contribution checklist (*)