A user seeks help implementing metafield search functionality in Shopify’s default search field, specifically for the Momentum theme v3.1.1. They found sample code but don’t know where to insert it.
Initial Solution (Dawn Theme):
EBOOST provides detailed instructions for Dawn theme users
Code snippets target two files: main-search.liquid and predictive-search.liquid
Screenshots show exact placement locations
Key Limitations Identified:
The basic code only works with free Shopify themes
Code only searches first 20 products in collection
Only works with single text type metafields in custom namespace
Multiple metafield types require an app solution
Advanced Implementation:
ri31 provides more sophisticated code for Horizon theme
Solution prevents duplicate results by tracking native search handles
Includes case-insensitive matching and concatenation of multiple metafields
Emphasizes this is a conceptual framework, not copy-paste solution
Status: Discussion remains open with no universal solution. Users with paid themes need either custom coding knowledge or developer assistance to adapt the code for their specific theme structure.
Summarized with AI on October 27.
AI used: claude-sonnet-4-5-20250929.
{% for product in collections.all.products %}
{% assign metafields = product.metafields %}
{% for metafield in metafields %}
{% if metafield.value contains search %}
{{ product.title }}
{% endif %}
{% endfor %}
{% endfor %}
I’m a novice when it comes to coding (I can understand it when I read it but that’s about it) and my question is: Where do I actually insert the code?
There are so many different sections and theme files that I just can’t figure out where it would go to effect the results obtained from the header search field. Any help would be greatly appreciated.
Thank you for the reply. I wish we were using the Dawn theme as those two section names would make it much easier. Unfortunately they decided on the Momentum theme v3.1.1 and for now that’s what I have to work with. They seem to have their own naming conventions for a lot of basic things.
Does this only work with your specific theme? It did not work for me. I am not really good with coding, so I do not understand whether I need to adapt the code snippet to include the name of the exact metafield and if so, how?
thank you for your reply. I have the BeYours Theme, by RoarTheme. I have the section called “predictive-search.liquid” too. Even though I entered the code snippet there, it did not work for me. Or do I need to publish that code to see it in action? So far I am adding a code to a duplicated theme in my library and then just check the preview.
Could you please tell us where to put this on our theme? Couldn’t find this line on our main-search but I know it’ll work on our theme if we can figure it out. Thanks! Using Canopy
I’m not sure I understand? We are looking for the metafield info to come up in search. We use alternative product names as some items have multiple names. These multiple names are not coming up in search since they are in metafield. I thought this code fixed that?