N
N
Nadezhda Golovina2021-03-11 16:59:33
1C-Bitrix
Nadezhda Golovina, 2021-03-11 16:59:33

Why don't numeric properties work in smart filter?

Hello.
Here on the site there is a Smart Filter on the left. It is part of the Catalog component. Properties of the "List" type work in it, filtering passes and the number of elements is displayed. But in the properties of the "Number" type, when the value or location of the slider is changed, the number of elements for output appears. BUT! It does not change and the filtering does not pass.
What could be the problem?
A piece of a component with filter parameters:

"FILTER_FIELD_CODE" => array(0=>"NAME",1=>"",),
    "FILTER_HIDE_ON_MOBILE" => "Y",
    "FILTER_NAME" => "arrFilter",
    "FILTER_PRICE_CODE" => array(0=>"CASH",),
    "FILTER_PROPERTY_CODE" => array(0=>"ATT_MATERIAL",1=>"ATT_STYLE",2=>"ATT_NUMBER",3=>"ATT_ROOM",4=>"ATT_APPOINTMENT",5=>"ATT_CHARACTERISTIC",6=>"ATT_HEIGT",7=>"ATT_WIDHT",8=>"ATT_DEPHT",9=>"",),
    "FILTER_VIEW_MODE" => "VERTICAL",

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-03-11
@Golovina90

There is a JCSmartFilter.prototype.gatherInputsValues ​​function in the filter template in the script.js file - there is some kind of jamb in it, if you turn off js merging in the main module, I can more accurately tell what the problem is. For the test, you can replace the default

spoiler

JCSmartFilter.prototype.gatherInputsValues = function (values, elements)
{
  if(elements)
  {
    for(var i = 0; i < elements.length; i++)
    {
      var el = elements[i];
      if (el.disabled || !el.type)
        continue;

      switch(el.type.toLowerCase())
      {
        case 'text':
        case 'textarea':
        case 'password':
        case 'hidden':
        case 'number':
        case 'phone':
        case 'email':
        case 'select-one':
          if(el.value.length)
            values[values.length] = {name : el.name, value : el.value};
          break;
        case 'radio':
        case 'checkbox':
          if(el.checked)
            values[values.length] = {name : el.name, value : el.value};
          break;
        case 'select-multiple':
          for (var j = 0; j < el.options.length; j++)
          {
            if (el.options[j].selected)
              values[values.length] = {name : el.name, value : el.options[j].value};
          }
          break;
        default:
          break;
      }
    }
  }
};


This function should have a case 'number': most likely, either it is missing or some kind of crooked logic is written there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question