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