I was working through rebuilding a website’s search page when I realized that pagination is forcing some products to move to page 2 instead of display in the order that I have them defined in the template. Is it possible to tell Shopify to “crawl” or search for products first, list them all out, then articles, and lastly pages?
Code for reference:
{% if search.performed %} {% paginate search.results by 12 %}
{% if check_product %} {% endif %}
{% for product in search.results %} {% if product.object_type == 'product' and product.available == true %}
{% include 'index-proditem' %}
{% endif %} {% endfor %}
{% if check_article %} {% endif %}
---
{% for article in search.results %} {% if article.object_type == 'article' and article.handle contains 'recipes' %}
{% if article.image %}
{% endif %}
## {{ article.title }}
{% if forloop.first == true %}{{ article.content | strip_html | truncatewords : 55 }}{% else %}{{ article.content | strip_html | truncatewords : 30 }}{% endif %}
{{ 'blogs.article.action'| t }}
{% endif %} {% endfor %}
{% if check_page %} {% endif %}
---
{% for page in search.results %} {% if page.object_type == 'page' %}
## {{ page.title }}
{% endif %} {% endfor %}
{% include 'pagination' %}
{% if paginate.current_page == 1 %} {% capture xnumber %}1{% endcapture%} {% else %} {% capture xnumber %} {{paginate.current_page | minus:1 | times: 8 | plus: 1}} {% endcapture%} {% endif %} {% capture ynumber%}{{paginate.current_page | times: 8 }} {% endcapture%} {% comment %}{% if paginate.pages == paginate.current_page %} {% capture ynumber %} {{search.results_count}} {% endcapture%}{%endif%} {{'collections.general.showing'|t:x:xnumber,y:ynumber,z:search.results_count}}{% endcomment %}
{% endif %} {% endpaginate %}