Followup for #2974512-9: Facets range widget directly alters the url.

+++ b/modules/facets_range_widget/src/Plugin/facets/processor/RangeSliderProcessor.php
@@ -46,25 +46,15 @@ class RangeSliderProcessor extends SliderProcessor implements PreQueryProcessorI
+      $new_active_filters[$facet->getUrlAlias()][] = '(min:__range_slider_min__,max:__range_slider_max__)';
+      $url = \Drupal::service('facets.utility.url_generator')->getUrl($new_active_filters, FALSE);

getUrl use keys to determine facet id's, not aliases

It should be:

$new_active_filters[$facet->id()][] = '(min:__range_slider_min__,max:__range_slider_max__)';
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

5n00py created an issue. See original summary.

5n00py’s picture

Status: Needs work » Needs review
FileSize
1003 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 2994859-facets_fix_range_processor.patch, failed testing. View results

5n00py’s picture

Status: Needs work » Needs review
FileSize
1.77 KB

Update tests.

michaellenahan’s picture

Status: Needs review » Reviewed & tested by the community

Thanks. I was hitting this error in facets/src/Utility/FacetsUrlGenerator.php

    $facet = $this->facetStorage->load($facet_id);
    if ($facet === NULL) {
      throw new \InvalidArgumentException("The Facet $facet_id could not be loaded.");
    }

After applying this patch, the correct $facet_id was passed to the facetStorage->load() function.

Marking as RTBC.

  • borisson_ committed 59f6406 on 8.x-1.x authored by 5n00py
    Issue #2994859 by 5n00py: Fix range slider processor's url generation
    
borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

matuspo’s picture

Hi everybody,

I came here as I got a problem with URL query params generation, when using range slider. The problem is, that anytime I change the slider values, it appends new query param instead of changing current one.

Example:
f[0]=variations_product_variation_cena_cislo%3A(min%3A3205%2Cmax%3A13705)&f[1]=variations_product_variation_cena_cislo%3A(min%3A3205%2Cmax%3A17305)&f[2]=variations_product_variation_cena_cislo%3A(min%3A405%2Cmax%3A17305)

As you can see it's same facet with different values.

I found that the patched line should be like this:

$new_active_filters[$facet->id()] = ['(min:__range_slider_min__,max:__range_slider_max__)'];

I tested it and now there is just one query parameter for specific facet.

jonas139’s picture

Hey Matuspo,

I was having the same problem but there's another active issue that maybe can help.
https://www.drupal.org/project/facets/issues/3055897