Hello ALL!
I want to enable SKU based search in search bar of shopify trade theme so I updated the fetch request for predictive search API but it is not working fine as it is not returning exact matched results. Below is the fetch request:
fetch(`${routes.predictive_search_url}?q=${encodeURIComponent(searchTerm)}&${encodeURIComponent('resources[options][fields]')}=title,product_type,variants.title,vendor,tag,variants.sku§ion_id=predictive-search`, {
signal: this.abortController.signal,
})
Below is the response for an SKU searched. The response does not include matched variant but I have noticed 1 thing that in the response the variants array is empty even this product has variants:
{
“resources”: {
“results”: {
“products”: [
{
“available”: true,
“body”: “The Madra Blush Tone Rug is a perfect addition to your home with beautiful colors and an intriguing, traditional pattern. This rug is carefully handmade by artisans made with jute and cotton. Add this rug to any room to add charming character with a natural touch.”
“title”: “Madra Blush Tone Area Rug”,
“type”: “Matrix Item”,
“variants”:
}
]
}
}
}
Can someone tell me what can be the issue ?