Okay
  Public Ticket #3618972
Filters
Open

Comments

  • Rodfrigo started the conversation

    Hello, 

    When I enter a collection the filters do not work even though I have them configured correctly here:

      https://admin.shopify.com/store/3cd610/apps/search-and-discovery/filters

    Can you help me to make them work? Please.


    Thanks.

    Attached files:  FILTERS.mp4

  • Rodfrigo replied

    Can you help me? 


    Thank you.

  • Rodfrigo replied

    Hello?


  • Rodfrigo replied

    Can you help me? 

    Thank you.

  • Rodfrigo replied

    And checking, the error is in the code that came in your template. 

    Can you help me to solve it, please.

    Attached files:  1.png
      2.png

  • Rodfrigo replied

    I solved the problem without the help of this support.

    I share the way I did it:

    The error indicates that the 'getAttribute' property of a value that is null cannot be accessed. The most common reason for this error is that an attempt is made to access a property of an element that does not exist or is not defined.

    Solution:

    Search for this line in main.js:

    parseInt(c.getAttribute("min"))==parseInt(d)&&parseInt(s.getAttribute("max"))==parseInt(p)&&&(n.splice(a,1),u.length>2&&&(l=l. replace("filter.v.price.gte=".concat(d,"&filter.v.price.lte=").concat(p,"&"),""),n.push(l))),i.onSubmitForm(n.join("&"),e)

    And replace it with this one:

    parseInt(c && c.getAttribute("min")) == parseInt(d) && parseInt(s && s.getAttribute("max")) == parseInt(p) && (n.splice(a, 1), u. length > 2 && (l = l.replace("filter.v.price.gte=".concat(d, "&filter.v.price.lte=").concat(p, "&"), ""), n.push(l))), i.onSubmitForm(n.join("&"), e))

    In this modification, c && c.getAttribute("min") and s && s.getAttribute("max") are used, which ensures that we first check if c and s are not null before trying to access their attributes with getAttribute. This avoids the error.