How can I convert a group of posts into woocommerce products

I created product catalogue on my wordpress site using wp posts and custom fields and now I want to transfer some categories of posts into woocommerce products through Mysql. just copy these posts to woocommerce – how can i do it? The categories remain the same.

Related posts

Leave a Reply

2 comments

  1. I have used this:

    global $wpdb;
     $wpdb->update(
     $wpdb->posts,
     array( 'post_type' => 'product', ),
     array( 'post_type' => 'post', ),
     // Data Type (available: %s string, %d integer, %f float)
     '%s',
     // SQL "WHERE" clause Type
     '%s'
    );
    

    and this

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