Thread Starter
Stefin
(@stepin)
Hi,
still waiting for the reply.
Is there any SQL command or some plugin that deletes products whose status is “Private” ?
thank you
Hey @stepin,
You may be able to use a plugin like one of these to do this more quickly than the standard built-in one.
https://wordpress.org/plugins/search/smart+manager/
Outside of that, I was not able to find any examples of this scenario online to pass along to you. This post has some SQL that you could use to remove all products. That could likely be refined to target only private ones.
https://www.storeapps.org/woocommerce-delete-all-products/
https://stackoverflow.com/questions/68139221/how-to-delete-woocommerce-products-that-belongs-to-specific-category-from-the-da
One of the downsides is this will leave all of the postmeta (custom fields) for these products in the database. With 30,000 products, that’s a lot of extra data that you don’t need anymore.
Another option would be to hire a developer to do this for you. There are freelance developers at Codeable who would be happy to help you out.
https://woocommerce.com/codeable/
Take care
Thread Starter
Stefin
(@stepin)
Hi,
thank you for in depth answer.
We found some code that says deletes meta data too,
DELETE wp_posts,wp_term_relationships,wp_postmeta,wp_term_taxonomy
FROM wp_posts
LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
LEFT JOIN wp_term_taxonomy ON ( wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id )
WHERE wp_posts.post_status='Trash';
As I understand it deletes “trash” posts, if we change it to “Private” it could delete private?
We want to be sure, because our database quite big 7+GB it would take long time to restore,
thank you
-
This reply was modified 1 year, 9 months ago by Stefin.