Duplicate Facet Summary Items

Created on 27 July 2020, over 4 years ago
Updated 9 March 2023, about 2 years ago

Steps to reproduce

The Facet Summary items are duplicate when the the item belongs to multiple parents in the tree. For instance, I am using a product categories taxonomy. "Mouth guards" term is under lacrosse, soccer, hockey,etc. The Facet summary "Mouth guards" shows 3 times.

Proposed resolution

I edited the theme preprocess function so we make sure same items are not repeated but we could probably fix this before the items are built?

🐛 Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

🇨🇦Canada adancillo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium herved

    I can confirm this issue, and it still applies for 2.x and 3.x.

    This happens when using hierarchical facets and having a taxonomy term active which has multiple parents.
    In this case DefaultFacetsSummaryManager::build will go through the results tree in buildResultTree and add any active result. Since it uses array_merge and there is no duplicates detection (e.g: that could be determined by the raw_value) we get multiple facets summary items.

    h4. Suggestion:
    We could simply use the raw_value as key and use the array union (+) operator instead in buildResultTree.
    Then in build we can leave array_merge (since 1 facet's raw_value could be the same as another facet's raw_value) but this can be changed to use the spread operator instead for performance.

  • Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    Waiting for branch to pass
  • 🇧🇪Belgium herved

    I found an issue with patch #3: if we have the same raw value between facets then we get only 1 facet summary item.
    This new patch uses "facet_ID:raw_value" as array keys to prevent duplicates and uses the + operator everywhere, which is more efficient.

  • Merge request !280Duplicate Facet summary items. → (Open) created by herved
  • Pipeline finished with Success
    2 months ago
    Total: 918s
    #408050
Production build 0.71.5 2024