How can I integrate SKU into predictive search on Fetch theme?

Jlundi04
Visitor
1 0 0

I want to be able to search by SKU on our stores search without the use of an app, however I am struggling on what code to implement and where since it doesn't exist by default in our theme's predictive search. We are using the Fetch theme by Archetype. 

Any help would be appreciated, 

Replies 3 (3)

gr_trading
Shopify Partner
1767 142 187

Hi

 

Search can only be performed on product title and description however, you can trick the search by putting your SKUs in the product description.

 

Hope this trick will help...

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee

Danny_Stetson
Visitor
1 0 0

Were you able to figure this out? I actually have the same theme and want to do the same thing. Let me know, thanks!

AutoPartsAAA
New Member
5 0 0

When I enter a SKU# into the default Shopify search bar in the header, the predictive search was not not showing results for the SKU I typed in partially or whole, even though when I click 'search' and am taken to a hard search results page, I do see the product with the SKU number I searched.

To fix this in Dawn 14.0 I had to edit assets/predictive-search.js

Look for the Fetch request and update as follows:

 fetch(`${routes.predictive_search_url}?q=${encodeURIComponent(searchTerm)}&resources[type]=product&resources[options][unavailable_products]=hide&resources[options][fields]=title,variants.sku,product_type,variants.title&section_id=predictive-search`,
     { signal: this.abortController.signal }
    )
      .then((response) => {
        if (!response.ok) {
          var error = new Error(response.status);
          this.close();
          throw error;
        }