Access search result before paginate

Tourist
16 0 1

Hi,

So I'm using theme named Ella and I'm trying to understand if it's possible to filter the search results. 
I want to filter the result by the tags it may or may not have, here is about what I did: 

{% assign grid_results = true %}
<div class="search-page">
  {% if search.performed %}
  {% comment %}
    Avoid accessing search.results before the opening paginate tag.
    If you do, the pagination of results will be broken.
  {% endcomment %}
  {% paginate search.results by 100 %}

  {% comment %}
    We don't have any results to show. Feel free to show off featured products
    or suggested searches here.
  {% endcomment %}
  
  {% if search.results_count == 0 %}
  <header class="page-header">
    <h2>{{ 'general.search.no_results_html' | t: terms: search.terms }}</h2>
    {% include 'search-bar' %}
  </header>
  {% else %}
  <header class="page-header">
    <h2>{{ 'general.search.results_for_html' | t: terms: search.terms }}</h2>
    {% include 'search-bar' %}
  </header>

  {% comment %}
    Each result template, based on the grid_layout variable above
  {% endcomment %}
  <div class="block-row">
    {% if grid_results == false %}
    <div class="product-list">  
      {% for item in search.results %}
      {% include 'search-result' %}
      {% endfor %}
    </div>
    {% else %}
    <div class="products-grid row">      
      {% for product in search.results %}
        {% for tag in product.tags %}
          {% assign temptag = tag | slice: 0 %}
          {% assign temptag2 = tag | slice: 2,1 %}
          {% if temptag == "#" and temptag2 != "_" %}
           {% assign mytag = tag %}
          {% endif %}
        {% endfor %}
        {% unless result_track contains mytag %}
          {% assign result_track = result_track | append: mytag | append:'|' %}
            <div class="{% if settings.product_image_border%}grid-item-border{% endif %}{% if settings.product_image_crop%} crop_image{% else %} no_crop_image{% endif %} grid-item col-xs-6 col-sm-4 {% if settings.display_sidebar_cat_page %}col-md-4{% else %}{% if product_grid == 3 %} col-md-3{% endif %}{% endif %} {% if columns %}col-lg-{{product_grid}}{% else %}col{% endif %}">
              {% include 'search-result-grid' %}
            </div>
          {% endunless %}
      {% endfor %}
    </div>
    {% endif %}
  </div>
  {% endif %}

  {% if paginate.pages > 1 %}
  <div class="text-center">
    {% include 'pagination-page' %}
  </div>
  {% endif %}
  {% endpaginate %}

 

You'll notice "result_track" , I basically store the tag that I found in the product and if the next product has the same tag, I'm not displaying the product. (that code works exactly as I need it to) 

My issue is, my theme uses infinite loader and when it loads the second page, "result_track" is being reset... 

I tried accessing search.result before the paginate tag, but it didn't seem to matter, so I just don't understand what is it that I'm suppose to do... 

I'm currently working on the search result page, but in general, I would want to do about the same in my collection pages, and it uses the same way of loading products (which I don't completly understand how to access) 
Any help will be highly appriciated. 


Thank you!

0 Likes
Highlighted
Tourist
16 0 1

anybody?

0 Likes