In this tutorial; We will learn how to mark status of all products to draft or any other status. We will achieve this by using a simple query.
Although We can simple update status using bulk edit but if we have large number of products WordPress may give us a time out error.
Let’s get along with it. I have a few products in my store marked as published.
Let’s say I want to change the status of these products to ‘draft’. To do this we need to execute following query either in phpmyadmin or any GUI db management tool.
UPDATE wp_posts SET post_status='publish' WHERE post_type='product'
After executing the query status of all products will be changed to draft.
Now, let’s say we just want to update status of products within a specific category. To do this we need to execute following query:
UPDATE wp_posts p JOIN wp_term_relationships r on p.id=r.object_id SET p.post_status='draft' WHERE r.term_taxonomy_id in (9, 10);
Replace the category ids in the query with ids of your categories. It will change the status of the products in specific categories. Thanks