Solved

Get all the collections that a product belongs to?

ClementBR
Shopify Partner
153 2 44

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? 

Accepted Solution (1)
_JB
Shopify Staff
836 100 222

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 | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 6 (6)

_JB
Shopify Staff
836 100 222

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 | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

ClementBR
Shopify Partner
153 2 44

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

_JB
Shopify Staff
836 100 222

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 | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

_JB
Shopify Staff
836 100 222

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 | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

ClementBR
Shopify Partner
153 2 44

Thanks, I had actually missed that.

Turns out it is in the docs:

 

ClementBR_0-1600417908890.png

 

_JB
Shopify Staff
836 100 222

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

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog