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

Issue with Non-Translatable Attribute Facets #259

Open
celiamaurewide opened this issue Nov 11, 2024 · 0 comments
Open

Issue with Non-Translatable Attribute Facets #259

celiamaurewide opened this issue Nov 11, 2024 · 0 comments

Comments

@celiamaurewide
Copy link

celiamaurewide commented Nov 11, 2024

Hello!
I am facing an issue when defining a facet for a non-translatable attribute. In Elasticsearch, non-translatable attributes are indexed with properties formatted as attribute_attributecode_ (without a locale suffix). However, the BitBag\SyliusElasticsearchPlugin\Facet\AttributeFacet class requires a LocaleContextInterface and always queries attribute_attributecode_localecode, even when the attribute is non-translatable. As a result, no results are returned for such facets.

For example, my configuration looks like this:

bitbag_sylius_elasticsearch_plugin.facet.attribute.filter_cooking:
    class: BitBag\SyliusElasticsearchPlugin\Facet\AttributeFacet
    arguments:
        - '@bitbag_sylius_elasticsearch_plugin.property_name_resolver.attribute'
        - '@=service("sylius.repository.product_attribute").findOneBy({"code": "filter_cooking"})'
        - '@sylius.context.locale' # here is the locale that is required by the class

BitBag\SyliusElasticsearchPlugin\Facet\AttributeFacet
private function getFieldName(): string
{
    return sprintf(
        '%s_%s.keyword',
        $this->attributeNameResolver->resolvePropertyName((string) $this->getProductAttribute()->getCode()),
        $this->localeContext->getLocaleCode() // This is where the locale causes a problem, as it is not nullable
    );
}

Is there an existing solution or workaround for this issue?

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

No branches or pull requests

1 participant