Delete orphans after import

This commit is contained in:
Mike Jolley 2018-03-13 11:14:24 +00:00
parent 387ea23d39
commit d910f11b49
1 changed files with 8 additions and 0 deletions

View File

@ -235,6 +235,14 @@ class WC_Admin_Importers {
AND {$wpdb->posts}.post_status = 'importing'"
);
// Clear orphan variations.
$wpdb->query(
"DELETE products
FROM {$wpdb->posts} products
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';"
);
// Send success.
wp_send_json_success(
array(