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

Can you search products by SKU in the product collection page?

Can you search products by SKU in the product collection page?

JTR
Pathfinder
98 12 49

Has anyone found a way to search products by SKU? I've had a look around at previous posts but all I've found is older posts saying it isn't yet possible, is it now possible?

<form class="search" action="/search">
<input type="text" class="collection-searchbar" placeholder="Search by SKU" name="q" value="{{ search.terms | escape }}" />
<input type="submit" value="Search" />
</form>

I tried the tutorial that makes it possible for the storefront search, but I'm trying to get it working for a search form I have in the product collection page.

Replies 6 (6)

Jason
Shopify Partner
11206 226 2315

You can search for a sku using the storefront search.

 

An example of a working search url is here:
https://jasons-experiments.myshopify.com/search?type=product&q=variants.sku:23200

Notice how the query must be in this format: "variants.sku:23200" where 23200 is the sku code. JavaScript would be needed to make sure the customer is redirected to the correctly formatted url.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
JTR
Pathfinder
98 12 49

Thanks, I followed your tutorial on creating the search.sku.liquid file, I've made that in snippets, just unsure on how to implement it.

 

    {% paginate search.results by 2 %}
      {% if search.performed %}
        {% for item in search.results %}
          <div class="grid__item" style="display: none !important"></div>
        {% endfor %}
      {% endif %}
    {% endpaginate %}

 Am I to replace the code above from search.liquid with {{ 'search.sku' }}

Arvindh
Visitor
1 0 0

I followed the steps in https://github.com/freakdesign/Shopify-code-snippets/tree/master/Search%20by%20SKU

Created a search.sku.liquid file and pasted the code.

search?type=product&q=variants.sku:220202

Am able to see the search result of the product. But, i am unable to route to the result page
when SKU is searched  in the search bar. 

Please guide me in this.

Thanks in Advance.!

BeWater
Shopify Partner
22 0 5

Does this super old code still work? I do not get it. Help please. Need to SKU search in 2022 for Dawn theme. 

jasondangsb
Shopify Partner
117 0 5

If you are open to a 3rd party app, this app allows you to search by product title, description, sku, barcode, option, metafield, collection and pages:  https://apps.shopify.com/ultimate-search-and-filter-1

Dario
Shopify Partner
10 0 0

Simply, you have to add your SKU into Product search enhancement METAFIELD created default BY SEARCH & CONSOLE APP 

It work fine without any custom code or theme modification. Function great with any theme

 Growth E-commerce Specialist
 Custom ERP Integration
 Shopify Evangelist

Join me in exploring the possibilities of e-commerce and optimizing your online presence!