How to Convert WordPress posts to products in WooCommerce

Recently I have a project that deals with many products in a website, while the existing website is not an eCommerce website. It’s sort of gallery or catalog of more than 500 products. But as the client wants eCommerce functionalist, I’ll find Woo Commerce plugin would do.

But I forgot that Woo Commerce has its own way to sort products, instead of using WordPress default posts to display products. You definitely won’t manually convert more 500 posts product to Woo Commerce products :D.

In the end I didn’t have to worry as I use this script to run SQL query to convert WordPress posts to Woo Commerce products

UPDATE  `wp_posts` SET  `post_type` =  'product' WHERE  `post_type` = 'post';

Please keep in mind that this query will change the post_type of every post to product. Having a backup of your DB before doing this is recommended. It would be even better if you use a (local) test installation and refine your update process there.

Optionally you can use this SQL query for converting the categories to product_cat

UPDATE `wp_term_taxonomy` SET `taxonomy`='product_cat' WHERE `taxonomy`='category'

Read more about it in WordPress Stack Exchange forum post thread.