Ad

How To Display Only Products In Shopify Search Results?

- 1 answer

I want to display only products from Shopify products but there are showing also pages and posts here is my code for search result:

<div class="product-list">
    {% if grid_results == false %}
    {% for item in search.results %}
    {% include 'search-result' %}
    {% endfor %}
    {% else %}
    <div class="grid-uniform">
      {% for item in search.results %}
      {% include 'search-result-grid' %}
      {% endfor %}
    </div>
    {% endif %}
    {% endif %}
  </div>

Now I got the following code:

{% if item.object_type == 'product' %}

But where to put this code so I can get only products for search any text.

Ad

Answer

Shopify has excellent self help guides for most of the stuff. Here's one such

Show only products in storefront search results

Ad
source: stackoverflow.com
Ad