Skip to content
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

GraphQl. How can I switch to use option id for filtering instead of option name. #3415

Open
zakdma opened this issue Oct 17, 2024 · 2 comments
Assignees
Labels

Comments

@zakdma
Copy link

zakdma commented Oct 17, 2024

Hi!
I'm creating the multi-language site using Nuxt as front and Magento as back communicating using GraphQl. ElasticSuite is installed on it.
ElasticSuite replaced Magento core search implementation to use filtering by attribute option name rather than option id.
It's ok in general but creates problems when using multiple languages where attribute options have different translations.
So when I switched to another language filters in the command line did not work because of different options names in different languages.
I want to switch to use option ids as filter values instead of names but can't find such settings in ElasticSuite configuration.
Could you please advice the best approach how to switch to use option ids programmatically?
I tried to plugin return \Smile\ElasticsuiteCore\Helper\Mapping::getOptionTextFieldName to return $fieldName and actually its working when the index already exists. But index is broken after reindex.

@romainruaud
Copy link
Collaborator

Hi @zakdma ,

we have plenty of headless multi-language websites running Elasticsuite through the GraphQl API and we did not notice this kind of issues.

Could you please share more details about what you consider as malfunctioning ?

Please share as well screenshot of your attributes configurations.

Regards

@zakdma
Copy link
Author

zakdma commented Oct 21, 2024

  1. Install vanilla Magento 2.4.7 with OpenSearch as a searching engine
  2. Create one more store view under default store group. Name it "Ukrainian" and "ua" is the store view code https://prnt.sc/HFV6IYkcE5Kr
  3. Edit default Color attribute and add two options "Red" and "Black" with Ukrainian translations "Червоний" and "Чорний" respectively. https://prnt.sc/zHJaib-f-ony
  4. Add Color attribute to Default attribute set.
  5. Create several simple products under some category with attribute color filled up.
  6. Instal ES composer require smile/elasticsuite ~2.11.0
  7. Configure it properly according to docs
  8. Reindex all and clear cache
  9. Open front and go to category with products
  10. Select Red in the layered navigation left panel https://prnt.sc/-XxKaMZdoUXO
  11. Switch to Ukrainian store view https://prnt.sc/Cahvahc0HIU4
  12. See incorrect filter without Red attribute value selected https://prnt.sc/Le6ozzCfe6d7

The problem is that attribute option text is used for filtering, not option_id. So switching to another language will break filtering because color=Red is not correct option value for Ukrainian store view. It should be color=Червоний instead.
We need to preserve filtering during store view (actual language) switching. So it would be good to use option_id as a attribute value for filtering (as vanilla Magento does) color=5 This ID will not change between languages. But looks like ES don't allow us to change filtering back to use option_id.
I'm looking for possibility how to do that or even better if you add this to configuration.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants