Delete all products in a collection

GrantDB
Explorer
48 2 8

Is there an easy way to remove all products in a collection?  I know I can loop through and delete, but that seems a bit intensive

Currently I delete the whole collection and recreate, but that doesn't seem a good way to do that

Thanks

Grant

0 Likes
JHKCreate
Shopify Partner
2052 333 447

Hi There!

Is it a manual or smart collection? If manual, you can select in batch on the Products page and do the following:

JHKC_0-1602842526297.png

 

Let me know!

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
GrantDB
Explorer
48 2 8

Apologies, I should have been clearer.

This would need to be through an api\graphql call and is a manual collection

Thanks

Grant

0 Likes
CalD
Shopify Staff
Shopify Staff
91 8 12

Hey @GrantDB,

Check out the collectionRemoveProducts mutation for this! Hope that helps.

CalD | Developer Support @ 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

0 Likes
surpriseshoppin
Excursionist
23 0 0

Hi JHKC.

 

I have tried deleting products from collection as stated in your message.

Please check and let me know and sorry for the delay.

 

 

 

From  Surpriseshoppin

0 Likes
GrantDB
Explorer
48 2 8

I used that mutation and it does work.  I was actually just hoping for a remove all (wildcard) rather than having to give all the product IDs

Thanks

Grant

0 Likes
surpriseshoppin
Excursionist
23 0 0

I am confused , dont know where we are at with this matter.

0 Likes
GrantDB
Explorer
48 2 8

I need to use the api and I need to loop through the products to delete them using collectionRemoveProducts.  There isn't the ability to delete the products through say a wildcard, delete all, leaving the empty collection in place.

Using collectionRemoveProducts will be OK for me, as the collection will only have 100 or so items, I should poll the job to see when it has finished, as mentioned in the docs

Thanks

Grant

 

surpriseshoppin
Excursionist
23 0 0

 

Can i ask you, what do you mean by poll the job? 

I have check collections and cant see any products.

0 Likes
GrantDB
Explorer
48 2 8

Not sure I understand what the question is.

https://shopify.dev/docs/admin-api/graphql/reference/mutation/collectionremoveproducts

The response for the request is a job id that should be polled

0 Likes