SHOW:
|
|
- or go back to the newest paste.
1 | - | -- MySQL Query to select all reviews that are assigned to a product and with review content |
1 | + | -- MySQL Query to export all Woocommerce reviews to a CSV file which can then be imported into Site Reviews |
2 | - | -- which can be used to export as a CSV and imported to the wp_comments table as WooCommerce reviews. |
2 | + | |
3 | -- 1. Install the [Database Browser](https://wordpress.org/plugins/database-browser/) plugin | |
4 | - | -- 1. Install the [Adminer](https://wordpress.org/plugins/pexlechris-adminer/) plugin |
4 | + | -- 2. Go to the "Tools > Database Browser" page |
5 | - | -- 2. Go to the "Tools > WP Adminer" page |
5 | + | -- 3. Click the "Select table" button (it doesn’t matter which table is selected) |
6 | - | -- 3. Click the "SQL command" link) |
6 | + | -- 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_`). |
7 | - | -- 4. Paste the SQL query (replace every instance of `wp_` in the SQL query with your table prefix) |
7 | + | -- 5. Click the "Edit query" button |
8 | - | -- 5. Click the "Execute" button |
8 | + | -- 6. Paste the SQL query, replacing every instance of `wp_` in the SQL query with your table prefix. |
9 | - | -- 6. Click the "Export" link, change the first dropdown to "save", then click the "Export" button |
9 | + | -- 7. Click the "Run query" button |
10 | - | -- 7. Go to the comments table and click "Select data" |
10 | + | -- 8. Click the "CSV" button to download the results |
11 | - | -- 8. Scroll to the bottom of the table and click the "Import" link |
11 | + | |
12 | - | -- 9. Select the CSV file you downloaded previously and click the "Import button |
12 | + | SELECT |
13 | c.comment_date as date, | |
14 | - | SELECT |
14 | + | c.comment_date_gmt as date_gmt, |
15 | - | ap.post_id as comment_post_ID, |
15 | + | cm.meta_value as rating, |
16 | - | r.name as comment_author, |
16 | + | c.comment_content as content, |
17 | - | r.email as comment_author_email, |
17 | + | c.comment_author as name, |
18 | - | r.ip_address as comment_author_IP, |
18 | + | c.comment_author_email as email, |
19 | - | p.post_date as comment_date, |
19 | + | c.comment_author_IP as ip_address, |
20 | - | p.post_date_gmt as comment_date_gmt, |
20 | + | c.comment_approved as is_approved, |
21 | - | p.post_content as comment_content, |
21 | + | c.comment_post_ID as assigned_posts, |
22 | - | r.is_approved as comment_approved, |
22 | + | c.user_id as user_id |
23 | - | 'review' comment_type, |
23 | + | FROM wp_comments AS c |
24 | - | p.post_author as user_id |
24 | + | INNER JOIN wp_commentmeta AS cm ON c.comment_ID = cm.comment_id |
25 | - | FROM wp_glsr_ratings AS r |
25 | + | WHERE 1=1 |
26 | - | INNER JOIN wp_posts AS p ON r.review_id = p.ID |
26 | + | AND c.comment_type = 'review' |
27 | - | INNER JOIN wp_glsr_assigned_posts AS ap ON r.ID = ap.rating_id |
27 | + | AND cm.meta_key = 'rating' |
28 | - | INNER JOIN wp_posts AS p2 ON ap.post_id = p2.ID |
28 | + | AND cm.meta_value IS NOT NULL |