Shopify: Remove product from collection via API call

无人久伴 提交于 2019-12-22 10:36:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!