Advertisement
geminilabs

Export reviews as WooCommerce reviews (WordPress comments)

Oct 28th, 2021 (edited)
1,469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.39 KB | None | 0 0
  1. -- MySQL Query to select all reviews that are assigned to a product and with review content
  2. -- which can be used to export as a CSV and imported to the wp_comments table as WooCommerce reviews.
  3.  
  4. -- 1. Install the [Adminer](https://wordpress.org/plugins/pexlechris-adminer/) plugin
  5. -- 2. Go to the "Tools > WP Adminer" page
  6. -- 3. Click the "SQL command" link)
  7. -- 4. Paste the SQL query (replace every instance of `wp_` in the SQL query with your table prefix)
  8. -- 5. Click the "Execute" button
  9. -- 6. Click the "Export" link, change the first dropdown to "save", then click the "Export" button
  10. -- 7. Go to the comments table and click "Select data"
  11. -- 8. Scroll to the bottom of the table and click the "Import" link
  12. -- 9. Select the CSV file you downloaded previously and click the "Import button
  13.  
  14. SELECT
  15.     ap.post_id as comment_post_ID,
  16.     r.name as comment_author,
  17.     r.email as comment_author_email,
  18.     r.ip_address as comment_author_IP,
  19.     p.post_date as comment_date,
  20.     p.post_date_gmt as comment_date_gmt,
  21.     p.post_content as comment_content,
  22.     r.is_approved as comment_approved,
  23.     'review' comment_type,
  24.     p.post_author as user_id
  25. FROM wp_glsr_ratings AS r
  26. INNER JOIN wp_posts AS p ON r.review_id = p.ID
  27. INNER JOIN wp_glsr_assigned_posts AS ap ON r.ID = ap.rating_id
  28. INNER JOIN wp_posts AS p2 ON ap.post_id = p2.ID
  29. WHERE p.post_content IS NOT NULL
  30. AND p2.post_type = 'product'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement