What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How do I get all the smart collections a product belongs to?

How do I get all the smart collections a product belongs to?

souravlaha
Shopify Partner
3 0 2

I need to get all the collections each product id belongs to. These collections are: smart and custom collections.

 

I was able to get the data needed by using GraphQL however, my client requires us to use the REST API.

 

In the documentation I found the following conflicting information:

 

Smart Collection documentation says: "The Collect resource is used to connect a product to a smart collection."

https://shopify.dev/docs/api/admin-rest/2023-04/resources/smartcollection#the-smart_collection-produ...

 

Collects documentation says: "Collects are for placing products in custom collections only. Smart collections use rules to determine which products are their members."

https://shopify.dev/docs/api/admin-rest/2023-04/resources/collect

 

How can I get the smart AND custom collections a product belongs to without me needing to iterate through all collections (smart and custom) available?

 

Ideally I want to just have an association like the collects table has which associates custom collection id and product id.

 

Why the collects table does not keep an association between smart collection and product id?

Replies 2 (2)

Tajs000
Shopify Partner
2 0 1

Did you manage to solve this?

Conde
Shopify Partner
1 0 1

Same issue