Quantcast
Viewing all articles
Browse latest Browse all 12

How to limit Shopify search results to a particular product type

Sometimes in Shopify you might want to modify the search on your site (store) so that only certain product types show up in the results.

If you go into the code of your search.liquid file and find the loop where the search results are output to the screen, you basically want to go in there and put in a conditional that says “only display these results if the product type is such and such.”

It will look something like this:

{% if item.type == 'Kitchen Supplies' %}
... stuff to output for each item here ...
{% endif %}

In the code above, we’re only going to display the search results for items that have a product type of “Kitchen Supplies.”

You could also modify the search using unless instead of if. Then the search would return all products except those with the product type specified by the unless.

{% unless item.type == 'Kitchen Supplies' %}
... stuff to output for each item here ...
{% endunless %}

There is more information about customizing searches on the storefront search page of the Shopify documentation. I didn’t completely understand everything on that page so I’m not sure the way I’ve described to code this above is the best way. If you have insight on this topic, feel free to share in the comments if you are so inclined.


Viewing all articles
Browse latest Browse all 12

Trending Articles