Delete all products in a collection

Highlighted
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
Highlighted
Shopify Partner
1079 171 198

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
K&J
Highlighted
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
Highlighted
Shopify Staff
Shopify Staff
79 8 11

Hey @GrantDB,

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

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
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
Highlighted
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
Highlighted
Excursionist
23 0 0

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

0 Likes
Highlighted
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

 

Highlighted
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
Highlighted
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