FROM CACHE - en_header

Predictive Search API with Multiple Languages

New Member
2 0 0

Noticing that Predictive Search API is returning results are coming back in the store's default language (English) in all cases. The store I'm testing in has both English and French. We translated a product and are retrieving results from the French title but the return values are all in English.


Here is an example of the results console logged with a function running in the window for testing.





The following is the testing code snippet written to run this window function.



const requestOptions = {
  method: 'GET',
  redirect: 'follow',
  headers: {
    'Accept-Language': 'fr'

function url (term) {
  return window.location.origin + '/search/suggest.json?resources[type]=product&q=' + encodeURIComponent(term)
} = function (term) {
  window.fetch(url(term), requestOptions)
    .then(response => response.text())
    .then(result => {
      const products = JSON.parse(result).resources.results.products
      console.log('Results:', products.length)
      console.log('Products:', products)
    .catch(error => console.log('error', error))



Let me know if there is anything amiss that is needed in the fetch that would ensure the return results are correct.

Reply 1 (1)
New Member
2 0 0

Reviewing the API document found here, it states that multiple languages are supported other than the body output. In our testing, the product titles are not outputting the translated language whether viewing the site from the primary or alternative language.