Home > OS >  Leveraging Shopify Predictive Search API
Leveraging Shopify Predictive Search API

Time:11-11

I'm trying to implement the predictive search API to create a custom solution when a product is out of stock. The idea is that we want to show an alternate product OF OUR CHOOSING (i.e. not using the automated recommendations). We have added a tag to all products with an alternate SKU that we want to show if an item is OOS. The Predictive Search API seems the perfect solution for this, but I can't get it to give me any results.

I found enter image description here

CodePudding user response:

I don't understand this, but it seems that the resources[options][fields] parameter is not only required, certain fields are required as well. In my case, I had to request the variants.sku field in order to get anything. Furthermore, that parameter is supposed to limit what you get, but it doesn't limit anything at all, I get everything.

Here are 2 sample URLs. The first one doesn't work, the second one does. Does anyone have any idea why???

https://example.com/search/suggest.json?q=searchstring&resources[type]=product&resources[options][fields]=title

VS

https://example.com/search/suggest.json?q=searchstring&resources[type]=product&resources[options][fields]=title,variants.sku

  • Related