Implementing Search by SKU

New Member
1 0 0

Hello Everybody,

Id like to be able to search by SKU on my storefront but it doesnt seem to work.
I stumbled upon this

https://freakdesign.com.au/blogs/news/search-for-a-shopify-product-by-sku

but im not exactly sure how to implement it.

Could someone help?

0 Likes
Shopify Partner
1838 173 573

Hi Richard,

First, let me say awesome store! Brought back ancient memories of my PE teacher teaching us square dance, do-so-do-ing and the lot.

Could you let us know what theme you are using? It would make it easier to help you out how to integrate @Jason's code from the article. Unless it's a commercial theme - that's difficult for forum members support.

Either way, let us know and once again, great store!

I turn coffee in to code - since 1998
0 Likes
Shopify Expert
9780 86 1531

That post is old, and needs to be updated to match the newer search format. I'll do that shortly.

The only change is how your refine the search to sku. Instead of something like this:
https://jasons-experiments.myshopify.com/search?type=product&q=sku:23200&view=sku

You'd do this:
https://jasons-experiments.myshopify.com/search?type=product&q=variants.sku:23200&view=sku

Note that sku has become variants.sku

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Shopify Partner
2 0 0

Our store search quit searching the SKU number and now searches the Barcode instead, there were no changes made to the code. This might have started happening about a month ago, would there have been any Shopify changes made that would have affected this?

0 Likes
Shopify Expert
9780 86 1531

What search url isn't working as expected? 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
3 0 0

@Jason I also need help with this issue on my site. We have lots of products we'll be uploaded, all with multiple variants. When a user needs to search by SKU, currently the site just returns the main product, not the variant SKU searched. This is bad UX as the user would have to click through each variant to find the SKU they want. Is there a solution to this

0 Likes
Shopify Expert
9780 86 1531

Your code handled the search so if you need to return the variant itself and not the product just loop over the variants to find the match. Once found, return that. Or return all and let some JS in the page do the picking of the correct variant.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like