How to update woocommerce products statuses to private in phpmyadmin

406 Views Asked by At

I want to change a specific range of products to "private".

I am using this query to display my products:

SELECT * FROM `wp_posts`
WHERE `ID` BETWEEN 2044 AND 2048
AND `post_type` = 'product'
ORDER BY `ID` ASC

I want to change post_status from "publish" to "private".

What will I write in console, can someone help?

phpMyadmin:

enter image description here

1

There are 1 best solutions below

0
Ruvee On

You could use the following sql query to change your products statuses:

UPDATE wp_posts 
SET post_status = 'private' 
WHERE ID BETWEEN 2044 AND 2048
AND post_type = 'product'

NOTE:

  • I've used wp_ as the table prefix. It's important to change it if your table prefix is different.
  • This query updates only the products where post_status is equal to 'product'.

To update all of products where post_status is equal to 'product' or 'product_variation', use the following sql query:

UPDATE wp_posts 
SET post_status = 'private' 
WHERE ID BETWEEN 2044 AND 2048
AND post_type = 'product'
OR post_type = 'product_variation'

This answer has been tested and works!