What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Make metafield vaules come up in the search bar?

Make metafield vaules come up in the search bar?

darkthrone
Shopify Partner
21 0 4

Hello,

I have some metafield values in my products on my shopify store. Is there any way to make the products show up in the search bar for them? I wrongly assumed this was something Shopify had built into it. 

Replies 2 (2)

EcomGraduates
Shopify Partner
784 68 112

Hello there  

 

Yes, it is possible to make the products show up in the search bar for metafield values in Shopify. However, it requires some customization to your Shopify theme.

To make the products show up in the search bar for metafield values, you can follow these steps:

  1. Create a new search input field in your Shopify theme. This can be done by modifying the theme's header or search template file.

  2. Use Liquid code to query the product metafields and search for any matches based on the search input.

 

{% for product in collections.all.products %}
  {% assign metafields = product.metafields %}
  {% for metafield in metafields %}
    {% if metafield.value contains search %}
      <a href="{{ product.url }}">{{ product.title }}</a>
    {% endif %}
  {% endfor %}
{% endfor %}

 

 

  1. Customize the code as needed to match your theme and search requirements. You can modify the search input field styling, search algorithm, and display format for the search results.

  2. Save the changes to your Shopify theme and preview the search functionality to ensure that it is working correctly.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



Wayzn
Visitor
2 0 2

IS there a similar approach that can be used to make order metafields searchable in the Shopify Admin main search or Orders search so we can find an order based on the value of one of its custom metafields?