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

Fix store specific attribute label on GraphQL products aggregations query #1896

Merged

Conversation

adinca
Copy link
Contributor

@adinca adinca commented Jul 31, 2020

When querying product aggregations using GraphQL, the returned attribute label is not always the correct one for the requested store view.

The issue is reproducible when the store views IDs are not consecutive.

Magento\Eav\Model\Entity\Attribute\AbstractAttribute::getFrontendLabels() returns an array of labels, where the key is numeric, starting from 0, however, Smile\ElasticsuiteCatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Attribute::build() function is expecting the key to be the store id.

To reproduce:

  1. Configure multiple store views where the IDs are not consecutive
  2. Set different attribute labels for each store view
  3. Use the following graphql query to fetch the aggregations:
query getProductFiltersByCategory {
    products(filter: { category_id: {eq: "2"} }) {
        aggregations {
            label
            count
            attribute_code
            options {
                label
                value
            }
        }
    }
}

(don't forget to change the category ID if you want to query a specific category filter list)

Also, you should set the specific store code when querying a store view

The expected result should include the correct store specific label, however, because of array key missmatch, we get labels from different stores.

@romainruaud romainruaud merged commit 63a7770 into Smile-SA:2.9.x Aug 3, 2020
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