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
Step 2: Go to Assets -> predictive-search.js -> Click on it
Step 3: Search for highlighted Line
Step 4: Add &resources[type]=product at the end of the URL as shown below and then click on the Save button.
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