-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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][Core][Checkout] Adding the isEnabled filter to the countries list in checkout while addressing. #15100
base: 1.12
Are you sure you want to change the base?
[FIX][Core][Checkout] Adding the isEnabled filter to the countries list in checkout while addressing. #15100
Conversation
7234d74
to
76893c1
Compare
Hey @christopherhero, could you please also cover this: Sylius/src/Sylius/Bundle/ApiBundle/Doctrine/QueryCollectionExtension/CountryCollectionExtension.php Lines 53 to 57 in baa1311
|
|
||
public function getEnabledCountries(): Collection | ||
{ | ||
return $this->getCountries()->filter(fn (CountryInterface $country): bool => true === $country->isEnabled()); |
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.
How about using criteria matching?
return $this->getCountries()->filter(fn (CountryInterface $country): bool => true === $country->isEnabled()); | |
return $this->getCountries()->matching(new Criteria(Criteria::expr()->eq('enabled', true))); |
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.
Right now the channel countries have eager fetch configured, but it might change in #14286
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.
How about using criteria matching?
Following simpler is better paradigm, filter might be more readable and more common occurrence in the source codes, there is only single matching()
in the whole codebase.
return $zoneMembers->matching(Criteria::create()->where(Criteria::expr()->eq('code', $code)))->first();
Right now the channel countries have eager fetch configured, but it might change in #14286
Should it be replaced with $countryRepository->findEnabledForChannel
instead?
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.
Should it be replaced with $countryRepository->findEnabledForChannel instead?
What you mean ?
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.
Thanks for PR @vvasiloi !
For me the filter
is more consistent with the rest of the code.
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.
@christopherhero in case of bigger collection relations, it's more optimal to make repository call instead of processing collection directly, but that's more of theoretical question what should be done for EAGER removal, if it will happen.
I've reproduced the issue, it can be re-tagged as bug. /cc @jakubtobiasz
|
@vvasiloi I will prepare another PR with the fix for the API. |
PR looks good code-wise, but I wonder should there be a scenario to cover those cases? On separate note,
It sounds like too many places needs to be modified to handle disabled counties within relation. |
…ist of countries in the addressing step on the cart - add test case to cover "getEnabledCountries" method
… `getCountries` in Sylius\Bundle\CoreBundle\Form\Extension\AddressTypeExtension
fe68689
to
33274bd
Compare
Bunnyshell Preview Environment deployedIt will be automatically stopped in 4 hours. Use the command
Available commands:
|
* @return Collection|CountryInterface[] | ||
* | ||
* @psalm-return Collection<array-key, CountryInterface> |
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.
Since psalm was dropped from the project
* @return Collection|CountryInterface[] | |
* | |
* @psalm-return Collection<array-key, CountryInterface> | |
* @return Collection<array-key, CountryInterface> |
This change restricts the list of available countries in the checkout->addressing step to those which are enabled.
Currently, when completing the address in checkout, all countries that are assigned to a channel are displayed, regardless of whether the country is enabled (country.enabled).