Focusing on managing products, variants, and collections through the API.
I need a structure on custom collections which allows me to change the products of the collection using the product_type, so when the product type changes, ALL the products of the collection needs to be changed. I figured i can add multiple products using the /custom_collections PUT endpoint like the following:
{ "custom_collection": { "collects": [ { "product_id": 1234 }, { "product_id": 1235 } ] } }
but that only adds products to the collection, doesn't remove them, so if i use it like this:
{ "custom_collection": { "collects": [] } }
it doesnt remove the old products. how can i remove/change all the products at once? is it possible?
Solved! Go to the solution
This is an accepted solution.
Hi Taylan,
It's possible that it might be easier to use the collectionRemoveProducts mutation, which is part of the GraphQL API - however you'll still need to provide product IDs. Would this work for you?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi Taylan,
It's possible that it might be easier to use the collectionRemoveProducts mutation, which is part of the GraphQL API - however you'll still need to provide product IDs. Would this work for you?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Yes that solved my problem, thanks!
Hi @Liam does this work for manual collections only? Then how to remove products from automatic collections? Thanks!