Skip to content

Conversation

@Nolwennig-Jeulin
Copy link
Contributor

related to : #7

@thomas-kl1
Copy link
Member

@Nolwennig-Jeulin, first of all, thank you for your contribution and the finding!

I've updated your PR and reworked your suggestion.
You are right that we should check for the default group, because you actually can have multiple group by websites.
Could you take a look on the changes and tell me if it works for you?

Regards,

@Nolwennig-Jeulin
Copy link
Contributor Author

@thomas-kl1 Thank you

But in my case the website domain_website is not the default website on my magento instance.
In all, we have 3 website on the same magento instance.

I check the updated code and the store_code returned is the first store we found : 25b700b#diff-ba18a31227c39c60c216c48a20fd0afbbd3d9a2eed2e17ec6309daee95273818R117

elseif (!isset($matches[3])) {
   // If nothing match, we use the first store we found

In my case this return by chance fr_fr (there is the first store_view in my first store_group)

If the default store_view is fr_en for the default group domain_store_fr , the return is by chance fr_en // nothing match, any default store has the priority

But, if my default store_group is domain_store_be, the result is again fr_en - // nothing match, any default store has the priority

The notion of default store_group is absent of the conditionnals statements

@thomas-kl1
Copy link
Member

You are right @Nolwennig-Jeulin
I'll try to find a way to factor this code.
As you said we should check for first priority for default website, then by default group, then by default store, then by any first store that match.

  1. Default Website - Default Group - Default Store
  2. Default Group - Default Store
  3. Default Store
  4. Any Store

@thomas-kl1
Copy link
Member

@Nolwennig-Jeulin I've reworked the code to use a score instead of complex conditional structure, it should be better and handle your case

@Nolwennig-Jeulin
Copy link
Contributor Author

@thomas-kl1 Nice !! Thank you

But I'm wonder at line 124

$score = in_array($store->getGroupId(), $website->getGroupIds()) ? 2 : 1;
in which cases the condition return false (with score:1)

The current store id (in the loop) is necessarily in a group of his website ?
The $website->getGroupIds() function return all group ids of the website ?

@thomas-kl1
Copy link
Member

thomas-kl1 commented Sep 9, 2025

Yup that's stupid me :)

It's because originally points were calculated like this:

Only default store = 1
Only default group + default store = 2
Only default website + default store = 3
Default website + default group + default store = 4

We just have to weight the default website as 2 points (the condition to check if group is part of default website is really stupid I agree bc always true)

@Nolwennig-Jeulin
Copy link
Contributor Author

!false ;)

No problem.

I wondered if I understood what I was seeing correctly, or if I had missed a feature I wasn't familiar with.

Thank you very much for your quick work and responsiveness.

Will this work be included in a release soon?

@thomas-kl1 thomas-kl1 merged commit 5d3ba5a into opengento:master Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants