Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 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 [Adminer](https://wordpress.org/plugins/pexlechris-adminer/) plugin
- -- 2. Go to the "Tools > WP Adminer" page
- -- 3. Click the "SQL command" link)
- -- 4. Paste the SQL query (replace every instance of `wp_` in the SQL query with your table prefix)
- -- 5. Click the "Execute" button
- -- 6. Click the "Export" link, change the first dropdown to "save", then click the "Export" button
- -- 7. Go to the comments table and click "Select data"
- -- 8. Scroll to the bottom of the table and click the "Import" link
- -- 9. Select the CSV file you downloaded previously and click the "Import button
- SELECT
- 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'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement