How can i use predictive search using SKU and UPC/Barcode in theme?

Hello, everyone i hope you all are doing well.

i have an question. In my theme i am using an predictive search in theme but if i use any sku or barcode its not search any product but if i hit enter then its go to search page and give me product that i search using sku/barcode, but that’s not what i want. What i want is if i search sku then its show an that product in predictive search i read some doc but i confused.

i want an proper ans for this because my client want’s this and i want to give an proper ans of this.

Thank you in advance.

By deafult, predictive search only searches title , product_type, variants.title , and vendor.

You can add variant sku to the list, but need to know your theme for exact answer.

Check the query parameters at Predictive Search API reference

Say, for Horizon family you need to find this line:

and add this line right below:

  url.searchParams.set('resources[options][fields]', 'title,product_type,variants.title,vendor,variants.sku');

Before /after (“lime sku” is the actual sku value for this product variant):



if my post is helpful, please like it ♡ and mark as a solution -- this will help others find it

Simplest stint is to just add the SKU to the title of the products, or the variants title but that can be a chore if you already don’t know what your doing.
Just export CSV and make a new title column in excel/g-sheets joining title and sku then reimport.
:bomb: SEO - This wont change existing urls but will show skus in search-engine results and without further theme customizations, and would always show in multi-channel, etc.

Otherwise it’s an advanced theme customization

This worked and it’s an incredible help. thanks life saver.