SKU to Predictive Search - Dawn theme - 2023

rcpro
Visitor
1 0 0

Hello Shopify community! 

I'm trying to add SKU to predictive search.
All solutions I found are not compatible with my theme.
Does any one know how to do so and can share with me? 
we have too many items to add the SKU to product title.
Thanks in advance!

screenshot for all search files 

rcpro_0-1698933767448.png

 

 

 

Reply 1 (1)

AutoPartsAAA
Tourist
7 1 0

I was able to get predictive search to include SKU in the Dawn 14.0 theme by editing assets/predictive-search.js

Look for the fetch and replace with:

 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;
        }