I’m working on a Shopify project and need to find all the collections associated with a specific product using its Product ID. For example, if "Red T-shirt" is a product that belongs to multiple collections, I want to retrieve the list of those collections.
Is it possible to achieve this using the Shopify Storefront API? If yes, which query or endpoint should I use? Are there any specific parameters or best practices for this use case?
Any help or sample code would be greatly appreciated.
2
Answers
In this link, you can easily find the topic
Retrieve a list of all smart collections for a certain product_id
With the SFAPI, use a query like this:
And the variable:
On the admin panel, you can install the GraphiQL app to test both Storefront and Admin api: https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/api-exploration/graphiql-storefront-api