Get all the collections that a product belongs to?

Solved
Highlighted
Shopify Partner
103 2 14

Up to this point, we have been using the Collect API to easily fetch all the collections that a product belongs to.

GET /admin/api/2020-07/collects.json?product_id=632910392

Unfortunately, there is a breaking change in recent API versions, and this call won't return collects from smart collections anymore.

That puts us in a tricky situation!

How can we retrieve all of the SMART collections that a product belongs to? 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
619 76 139

Hey @ClementBR,

This change was implemented starting with 2020-01, more details in our API blog here. The reason for the change is that we're planning to move away from collects altogether, which will allow products in collections to be queried with the new endpoint /collection/{{ collection_id }}/products.json. 2020-01 introduced this change for smart collections, and you can expect to see further changes to the collection resource in the future. Keep an eye on the changelog for those announcements.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
103 2 14

I'm aware yes. But what about my question?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
619 76 139

Ah sorry, read your question backwards at first.

Totally understand the concern, so I've raised the question with our product team for clarification. I'll post back here with new info once I have it.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
619 76 139

This is an accepted solution.

Hey @ClementBR,

Just got clarification that this functionality actually is implemented, you can get all smart_collections a product belongs to using the smart collections endpoint with a query string for product_id:

GET /admin/api/{{ api_version}}/smart_collections.json?product_id=1234567890

Thanks for bringing this up, we'll look in to why this isn't in the documentation.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
103 2 14

Thanks, I had actually missed that.

Turns out it is in the docs:

 

ClementBR_0-1600417908890.png

 

1 Like
Highlighted
Shopify Staff
Shopify Staff
619 76 139

D'oh! Not sure how I missed that, but thanks for pointing it out. 

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes