From 5d7aa234b011a908590b4cca72b7a5e437924868 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 19 Apr 2017 10:35:39 +0100 Subject: [PATCH] wc_update_300_grouped_products update routine needs to unset the post_parent on grouped products Fixes #14507 --- includes/wc-update-functions.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php index df048f7f18b4..65ad23e119a6 100644 --- a/includes/wc-update-functions.php +++ b/includes/wc-update-functions.php @@ -1020,7 +1020,18 @@ function wc_update_300_grouped_products() { 'post_type' => 'product', 'fields' => 'ids', ) ); - add_post_meta( $parent_id, '_children', $children_ids, true ); + update_post_meta( $parent_id, '_children', $children_ids ); + + // Update children to remove the parent. + $wpdb->update( + $wpdb->posts, + array( + 'post_parent' => 0, + ), + array( + 'post_parent' => $parent_id, + ) + ); } } }