问题
I'm trying to use the Shopify API to remove products from a collection.
In the docs (https://docs.shopify.com/api/collect) overview it says:
DELETE /admin/collects/#{id}.json
Remove a Collect from the database
While when you jump to the description it says:
Remove a product from a collection
Destroy the link between a product an a collection
DELETE /admin/collects/#{id}.json
So can I use this to remove a product form a collection or remove a collection from the DB?
And if it's possible to remove a product from a collection - what I want to do - shall I pass the collection ID or the product ID - actually I think I have to pass both, or how shall it work otherwise?
Thanks for your help!
回答1:
Collect is the join table for a many-to-many relationship between a product and a collection. It has its own id. To remove the product from a collection you are just removing the join so you only have to use the collect id not the product id or the collection id.
If you have the product id and the collection id you can get the collect id via:
GET /admin/collects.json?product_id=1925263361&collectionid=29722105
来源:https://stackoverflow.com/questions/32710211/shopify-remove-product-from-collection-via-api-call