Merge pull request #20094 from woocommerce/fix/20051

When cleaning up CSV import, only remove product taxonomies
This commit is contained in:
Gerhard Potgieter 2018-05-18 14:30:45 +01:00 committed by GitHub
commit 7302d21a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -258,11 +258,15 @@ class WC_Admin_Importers {
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->postmeta}.post_id
WHERE wp.ID IS NULL
" );
// @codingStandardsIgnoreStart.
$wpdb->query( "
DELETE {$wpdb->term_relationships}.* FROM {$wpdb->term_relationships}
LEFT JOIN {$wpdb->posts} wp ON wp.ID = {$wpdb->term_relationships}.object_id
DELETE tr.* FROM {$wpdb->term_relationships} tr
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
LEFT JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE wp.ID IS NULL
AND tt.taxonomy IN ( '" . implode( "','", array_map( 'esc_sql', get_object_taxonomies( 'product' ) ) ) . "' )
" );
// @codingStandardsIgnoreEnd.
// Send success.
wp_send_json_success(