Export reviews as WooCommerce reviews (WordPress comments)
Oct 28th, 2021 (edited)
- -- MySQL Query to select all reviews that are assigned to a product and with review content
- -- which can be used to export as a CSV and imported to the wp_comments table as WooCommerce reviews.
- -- 1. Install the [Database Browser](https://wordpress.org/plugins/database-browser/) plugin
- -- 2. Go to the "Tools > Database Browser" page
- -- 3. Click the "Select table" button (it doesn’t matter which table is selected)
- -- 4. Copy the table prefix of your tables (for example, if the table is `wp_posts`, the prefix is the first part with the underscore `wp_`).
- -- 4. Click the "Edit query" button
- -- 5. Paste the SQL query, replacing every instance of `wp_` in the SQL query with your table prefix.
- -- 6. Click the "Run query" button
- -- 7. Click the "CSV" button to download the results
- ap.post_id as comment_post_ID,
- r.name as comment_author,
- r.email as comment_author_email,
- r.ip_address as comment_author_IP,
- p.post_date as comment_date,
- p.post_date_gmt as comment_date_gmt,
- p.post_content as comment_content,
- r.is_approved as comment_approved,
- 'review' comment_type,
- p.post_author as user_id
- FROM wp_glsr_ratings AS r
- INNER JOIN wp_posts AS p ON r.review_id = p.ID
- INNER JOIN wp_glsr_assigned_posts AS ap ON r.ID = ap.rating_id
- INNER JOIN wp_posts AS p2 ON ap.post_id = p2.ID
- WHERE p.post_content IS NOT NULL
- AND p2.post_type = 'product'
Please, Sign In to add comment