Open Nuranto opened 12 months ago
Hello @Nuranto,
I was able to reproduce your issue. Indeed the attribute options translation does not work through any language (e.g. fr_FR
) translation file no matter if it's using the custom source model or default. This is due to the fact that Elasticsearch indexes an Apple
value, so if you try to search Pomme
you don't find any products.
We're not a huge fan of adding an emulate store somewhere in the index rebuilding process. As an easy solution, Magento proposes a way to add translation via Admin Panel -> Attribute Properties -> Manage Options (Values of Your Attribute)
. Therefore I have a question, why you are using a custom source model and why is translation via Admin not suitable for you?
BR, Vadym
Hi @vahonc,
It reminds me a similar question from Romain here : https://github.com/Smile-SA/elasticsuite/issues/2932
Here are some examples :
country_of_manufacture
(Both example are not very relevant regarding translation, but you get the idea)status
, price_type
, shipment_type
, ...Maybe store emulation is not necessary. Maybe locale emulation is enough (Magento\Framework\Locale\Resolver::emulate()
) ?
- An attribute that has a dynamic source. For example, you may want to create a Model/DB schema/CRUD for brands, and link those to products, so you can then easily, for instance, add a link to the custom brand page on product view, or display extra brand informations, etc.. Native attribute example :
country_of_manufacture
(Both example are not very relevant regarding translation, but you get the idea)
In any case, this is exactly what does these 2 modules :
https://github.com/Smile-SA/magento2-module-custom-entity https://github.com/Smile-SA/magento2-module-custom-entity-product-link (this one requires Elasticsuite)
I wasn't aware about those modules, and it looks great. I'll definitely look into it, however that won't solves the other 2 cases
Preconditions
Magento Version : 2.4.6-p3
ElasticSuite Version : 2.11.4.1
Steps to reproduce
[ ['value'=>1, 'label' => __('Apple')->render()], ['value'=>2, 'label' => __('Car')->render()]. ]
Expected result
Actual result
Additional informations
Quick fix I found is to manually load translations in my source model :
But that's obviously not a good solution, that should be done somewhere in smile module. I did not found the correct place to do it though, we should probably emulate store somewhere in index rebuilding process.
EDIT : This solution does not work, it loads the translations, yes, but does not reload it for each store. So it just solve the problem to one store, and move the issue to the other one. So we definitely need store emulation here.