monsieurbiz / SyliusSearchPlugin

A search plugin using Elasticsearch for Sylius
MIT License
45 stars 38 forks source link

fix: index translations correctly for taxons and attribute value #209

Closed delyriand closed 5 months ago

delyriand commented 5 months ago

Without this patch, data indexed in ES is in the default locale.

In Sylius, we have a postLoad on entities to add the current locale on the translation entity. But in CLI, it uses the default locale ('%locale%'):

        $fallbackLocale = $this->translationLocaleProvider->getDefaultLocaleCode();
        $translatableEntity->setFallbackLocale($fallbackLocale);

        if ($this->commandBasedChecker !== null && $this->commandBasedChecker->isExecutedFromCLI()) {
            $translatableEntity->setCurrentLocale($fallbackLocale);

            return;
        }

We should see if we can't add a similar behavior to the plugin to simplify the code.