Re: How can I include tags in Debut theme's predictive search?

How can I include tags in Debut theme's predictive search?

PurpleMamba
Shopify Partner
126 1 18

I'm using Debut theme and although the Shopify docs say that product tags are searched, they are not included in the predictive search.

Since customers never search just the product title, is there a way to include product tags in the predictive search?

Reply 1 (1)

Svenson
Shopify Partner
2 0 1

Hi @PurpleMamba,

the predictive search does not include "tag" by default (only "title", "product_type", "variants.title", and "vendor". See section "fields" in documentation).

Also the Debut theme uses an own search configuration to override the default behaviour, but it does also not include the "tag" field yet.

To change this, go to assets/theme.js and look for the "DEFAULT_PREDICTIVE_SEARCH_API_CONFIG" (around line 1372). It should look like this:

 

var DEFAULT_PREDICTIVE_SEARCH_API_CONFIG = {
  resources: {
    type: [PredictiveSearch.TYPES.PRODUCT],
    options: {
      unavailable_products: PredictiveSearch.UNAVAILABLE_PRODUCTS.LAST,
      fields: [
        PredictiveSearch.FIELDS.TITLE,
        PredictiveSearch.FIELDS.VENDOR,
        PredictiveSearch.FIELDS.PRODUCT_TYPE,
        PredictiveSearch.FIELDS.VARIANTS_TITLE
      ]
    }
  }
};

 

 

Now add the "tag" (PredictiveSearch.FIELDS.TAG) as searchable field at the bottom. In the end, the whole block should look like this:

 

var DEFAULT_PREDICTIVE_SEARCH_API_CONFIG = {
  resources: {
    type: [PredictiveSearch.TYPES.PRODUCT],
    options: {
      unavailable_products: PredictiveSearch.UNAVAILABLE_PRODUCTS.LAST,
      fields: [
        PredictiveSearch.FIELDS.TITLE,
        PredictiveSearch.FIELDS.VENDOR,
        PredictiveSearch.FIELDS.PRODUCT_TYPE,
        PredictiveSearch.FIELDS.VARIANTS_TITLE,
        PredictiveSearch.FIELDS.TAG
      ]
    }
  }
};

 

 

Reload your page. Now, the predictive search takes product tags into account.

By the way, I am using Version "17.6.0" of the Debut theme.