How to restrict search function to products only on Dawn theme?

Hello there,

I’m using the Dawn theme, I want to make the search function to be only searching for products. After some research, I’ve found this code

I’ve put it in this section of main-search.liquid


The code works half of the time. When searching using the search form in the header, it return results for everything. But on the search results page, there's another search form, if I search from that search form, the results is for product only.

Here's my website

[www.ikuono.com](http://www.ikuono.com) - try searching "high top sneaker"

Thank you :slightly_smiling_face:

Improve

to


Helps remove the chance of parse errors

And try it again.

Hi Paul,

Did that, didn’t work :disappointed_face:

+1!!!
Can’t get this to work in Dawn theme main-search.liquid code
Shopify .dev Docs don’t have proper documentation for filtering search results on OS 2.0 Themes.

~~ @zoombie I see you got this working on your site! Mind sharing your knowledge?~~Never mind, I see the page results at the bottom of the search now :disappointed_face:

:folded_hands:t3:

@zoombie If you add the same code to the Header.liquid file, that will solve your problem.

Search in header.liquid for the same function (form action…) and add the same code Paul provided.

I’ve been trying to figure this out for 2 days… that solved it for me.

Hi all, the code has worked on Desktop view but not Mobile. Does anyone have a solution to fix this?