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

Visual swatches values not displayed in the right order in the filters #1503

Closed
LilyBergonzatOld opened this issue Aug 12, 2019 · 11 comments
Closed
Assignees
Labels

Comments

@LilyBergonzatOld
Copy link

When a filter is a visual swatch, its values won't respect the order defined in the attribute administration (for example: number of results).

Preconditions

Have an attribute being a visual swatch, with multiple values.
Have each of those values return a different amount of products.

Magento Version : 2.3.2
ElasticSuite Version : 2.8.1
Environment : Production
Third party modules : None (tested in a vanilla Magento, with just ElasticSuite enabled, and Luma theme)

Steps to reproduce

  1. Set a visual swatch attribute values sort order (facet sort order) to "Result count"
  2. Load a category page that display the previously configured attribute as a filter

Expected result

  1. The values are displayed in the set order, starting with the one that has the most results, ending with the one that has the least results.

Actual result

  1. The values are displayed following the admin manually set order.
@LilyBergonzatOld
Copy link
Author

Actually there seems to be the same problem on the category filter. Don't know if it's only "visual swatches and category" or just all filters though. Some of them are working just great!

@rbayet
Copy link
Collaborator

rbayet commented Aug 21, 2019

Hello @YannBergonzat,

I've looked into it : the elasticsearch query is OK (aggregation uses the correct sort order) and the list of items come out ok in \Smile\ElasticsuiteCatalog\Model\Layer\Filter\Attribute whatever the attribute type.

The issue with the visual swatches attributes is that the custom template vendor/magento/module-swatches/view/frontend/templates/product/layered/renderer.phtml and renderer \Magento\Swatches\Block\LayeredNavigation\RenderLayered take over and list options in their admin sort order.

It does not seem limited to Magento 2.3.x or even 2.2.x, I'll look into but it might have been there since the earliest Magento2/Elasticsuite versions, I'll check with @romainruaud.

Regards,

@romainruaud
Copy link
Collaborator

@androshchuk @serg6854 can you handle this one ?

@romainruaud
Copy link
Collaborator

I'll review PR #1550 but in the meantime @YannBergonzat can you check that PR #1550 is also fixing the issue on your environment ?

Regards

@LilyBergonzatOld
Copy link
Author

It seems to be fixed, indeed 🙌:tada: ! Thank you!

@LilyBergonzatOld
Copy link
Author

Oops, my bad, I only checked the swatches!

The category filter doesn't seem to be fixed. It has the same bug, as my comment states.

Can you look into that please? @androshchuk @serg6854 @romainruaud

@androshchuk
Copy link
Contributor

Hello, @LilyBergonzat

Could you please provide steps to reproduce this bug with category filter?

Regards

@LilyBergonzatOld
Copy link
Author

Hello @androshchuk

The steps are almost the same, except at step 1, you set a category filter instead of a swatch:

The values of the category filter won't respect the order defined in the attribute administration (for example: number of results).

Magento Version : 2.3.2
ElasticSuite Version : 2.8.1
Environment : Production
Third party modules : None (tested in a vanilla Magento, with just ElasticSuite enabled, and Luma theme)

Steps to reproduce

  1. Set the category attribute values sort order (facet sort order) to "Result count"
  2. Load a category page that display the category filter with multiple values

Expected result

  1. The values are displayed in the set order, starting with the one that has the most results, ending with the one that has the least results.

Actual result

  1. The values are displayed following the admin manually set order.

@androshchuk
Copy link
Contributor

Hello @LilyBergonzat

Unfortunately, I can't reproduce the issue, because I don't have attribute type "category filter" http://joxi.net/a2XGVDDIwX4ddm .

I think you confused the subcategories with the filter (this is subcategory http://joxi.net/Q2KBn44CLDwpdm and they aren't sorted by Name or Result count).

Sample data has an attribute that simulates categories (Category Gear), but it's really multiple select http://joxi.ru/bmo9oddh3B7RPA and it works fine http://joxi.net/p273811TKeN7B2 (by Name), http://joxi.ru/zANj044CvY1lkA (by Result count).

Let me know if the issue is not resolved.

Regards

@romainruaud
Copy link
Collaborator

I think @LilyBergonzat is speaking about the category_ids attribute.

This attribute is a bit special in Magento (it's a system attribute), and it's highly probable that when building the category filter we are not using the configuration that could exist in the category_id attribute because the Category facet is not built from an attribute like the other filters :

a "legacy" filter, based on attributes (we do use the configuration like facet_max_size, facet_sort_order etc...) : https://github.com/Smile-SA/elasticsuite/blob/2.8.x/src/module-elasticsuite-catalog/Model/Layer/Filter/Attribute.php

the category filter (it's also overriden in the Virtual Category module but the logic is the same, it's not based on an attribute so we never load any associated model) : https://github.com/Smile-SA/elasticsuite/blob/2.8.x/src/module-elasticsuite-catalog/Model/Layer/Filter/Category.php

@LilyBergonzat is this the issue you are speaking about ? Can you create another ticket to handle this issue, so that it will be easier for us to track them as separate issue (since the problem related to the swatches is fixed).

Regards

@LilyBergonzatOld
Copy link
Author

It is, indeed! I will create another ticket, thank you :) !

rbayet pushed a commit that referenced this issue Oct 16, 2019
* Fixes #1503 fix sorting in Visual Swatches attribute

* Fixes #1503 add documentation to the overridden method
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

5 participants