Searching in Storefront API' fetchByHandle by handle with typo

Solved

Searching in Storefront API' fetchByHandle by handle with typo

sewerynzeman
Shopify Partner
7 1 3

Hi, let me get straight to an example:

 

I have a product linked on the webpage:

https://store.177milkstreet.com/products/fuji-cutlerly-fa-70-chinese-style-cleaver

 

When you visit, you'll find out that it redirects you to:

https://store.177milkstreet.com/products/fuji-cutlery-fa-70-chinese-style-cleaver

 

What is the difference? Well – a typo: "cutlerly" vs "cutlerly".

 

Shopify does the good job to discover that it is a typo, but in my system I'm using this product handle extracted from URL. When I get one from the link, API responds:

```

{ "data": { "productByHandle": null }}

```

 

What kind of mechanism is behind Shopify Store itself to discover the proper product? Is there any change to get it the same way in Storefront API?

 

Thanks!

Accepted Solution (1)

sewerynzeman
Shopify Partner
7 1 3

This is an accepted solution.

If anyone would look for an answer in this topic, this is what we ended up:

 

1. URL redirects are responsible for this mechanism, but they only work for Online Store and not API.

2. Storefront API actually defined UrlRedirect object to get a list of all redirects, but this is not yet available in any stable version of the API.

3. You can browse it and use it in Unstable API version.

 

As a solution we decided to drop UrlRedirect object API and create super-simple microservice that requests for broken URLs and listens if they respond with 301 Redirect. If they do – we return new URL in response, which contains a product handle that is queryable.

 

My personal opinion is that Shopify should store not "URL redirects" but whole handles for product history and use it for URL but also API requests.

View solution in original post

Reply 1 (1)

sewerynzeman
Shopify Partner
7 1 3

This is an accepted solution.

If anyone would look for an answer in this topic, this is what we ended up:

 

1. URL redirects are responsible for this mechanism, but they only work for Online Store and not API.

2. Storefront API actually defined UrlRedirect object to get a list of all redirects, but this is not yet available in any stable version of the API.

3. You can browse it and use it in Unstable API version.

 

As a solution we decided to drop UrlRedirect object API and create super-simple microservice that requests for broken URLs and listens if they respond with 301 Redirect. If they do – we return new URL in response, which contains a product handle that is queryable.

 

My personal opinion is that Shopify should store not "URL redirects" but whole handles for product history and use it for URL but also API requests.