For a product which does not belong to any collection we can have url defined as - <shop-url>/products/< product.handle >
. In case a product belongs to a collection it changes to - <shop-url>/collections/<collection-name>/products/< product.handle >
. Is there any third case also?
How to handle these cases. Also, I do not get the collection name attached to the product when I make an api call so that I may build upon the url myself. Is there a generic way to get the product url when fetching product via api call?
I wonder why shopify does not provide with the product url straightways! Is there any reason?
EDIT:
I just realized that even if a product is associated with a collection we can have its url as <shop-url>/products/< product.handle >
; and <shop-url>/collections/<collection-name>/products/< product.handle >
are same thing. Two different url but same page?
In liquid you can access a product's URL with product.url
, which outputs /products/handle
. It doesn't look like the URL is available via the API, but you could easily build the URL with the product's handle (which you can get via the API).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments