diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index 05b9c11ea5b..bebe513af19 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -1359,8 +1359,10 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller { } elseif ( $object->is_type( 'grouped' ) ) { foreach ( $object->get_children() as $child_id ) { $child = wc_get_product( $child_id ); - $child->set_parent_id( 0 ); - $child->save(); + if ( ! empty( $child ) ) { + $child->set_parent_id( 0 ); + $child->save(); + } } }