How to display only products in search results Liquid Shopify

How to display only products in search results Liquid Shopify

Shopify provides predictive search API to search products, collections, articles, and pages. By default in the Shopify theme, it searches for all things like products, collections, articles, and pages. Often, you just want to display searched products in the list, not collections, articles, and pages.

There is the easiest way to display only products in search results. Let’s start.

Changes to display only products in search results

Step 1: Go to Online Store -> Themes -> your theme -> Click on 3 dots -> Edit code

Image explaining how to go to themes editor

Step 2: Go to Assets -> predictive-search.js -> Click on it

Image showing to open predictive search JS file

Step 3: Search for highlighted Line

Highlighting modifying code line for predicitve seatch API

Step 4: Add &resources[type]=product at the end of the URL as shown below and then click on the Save button.

Adding displayed code at the end of predictive search API URL

Hurrah 🎉🎉 That’s it. Now Go to your website and try to search, it will only show products.

For Articles, Collections, and Pages

If you want to search for the combinations of Products + Articles, Products + Collections, or Products + Pages, you just need to add arguments in the URL.

Products + Articles => &resources[type]=product,article
Products + Collections => &resources[type]=product,collection
Products + Pages => &resources[type]=product,page
Products + Articles + Collections => &resources[type]=product,article,collection

For more details about search results, please visit Shopify’s Search Doc

You might also Like: How to format date in Liquid Shopify

Hardik Davra
Hardik Davra
Hardik Davra is a CEO at Candisoft Tech, a Company specializing in Shopify Development. I have over 5 years of experience in Shopify website development.

Leave a Reply

Your email address will not be published. Required fields are marked *