diff --git a/includes/data-stores/class-wc-product-variation-data-store-cpt.php b/includes/data-stores/class-wc-product-variation-data-store-cpt.php index 81726f909e2..f094318d3c6 100644 --- a/includes/data-stores/class-wc-product-variation-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-variation-data-store-cpt.php @@ -70,19 +70,15 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl $this->read_product_data( $product ); $product->set_attributes( wc_get_product_variation_attributes( $product->get_id() ) ); - error_log( print_r( $product_name, 1 ) ); - - if ( __( 'Variation #', 'woocommerce' ) === substr( $product_name, 0, 11 ) ) { - error_log( 'clean up' ); - error_log( print_r( $product_name, 1 ) ); + // Clean up old variation titles. + if ( __( 'Variation #', 'woocommerce' ) === substr( $product_name, 0, 11 ) || ( 'Product #' . $product->get_parent_id() . ' Variation' ) === $product_name ) { $parent_data = $product->get_parent_data(); - $new_title = $parent_data['name'] . ' – ' . wc_get_formatted_variation( $product, true, false ); + $new_title = $parent_data['name'] . ' – ' . wc_get_formatted_variation( $product, true, false ); $product->set_name( $new_title ); wp_update_post( array( 'ID' => $product->get_id(), 'post_title' => $new_title, ) ); - error_log( print_r( $new_title, 1 ) ); } // Set object_read true once all data is read.