Get all the collections that a product belongs to?

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?

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.

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

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.

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.

Thanks, I had actually missed that.

Turns out it is in the docs:

1 Like

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