Merge pull request #19595 from woocommerce/fix/19562

Trigger post modified update when saving products and variations, but no other product data
This commit is contained in:
Claudio Sanches 2018-04-03 12:23:10 -03:00 committed by GitHub
commit d043e4727b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -221,6 +221,19 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
wp_update_post( array_merge( array( 'ID' => $product->get_id() ), $post_data ) );
}
$product->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
} else { // Only update post modified time to record this save event.
$GLOBALS['wpdb']->update(
$GLOBALS['wpdb']->posts,
array(
'post_modified' => current_time( 'mysql' ),
'post_modified_gmt' => current_time( 'mysql', 1 ),
),
array(
'ID' => $product->get_id(),
)
);
clean_post_cache( $product->get_id() );
}
$this->update_post_meta( $product );

View File

@ -207,6 +207,19 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
wp_update_post( array_merge( array( 'ID' => $product->get_id() ), $post_data ) );
}
$product->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
} else { // Only update post modified time to record this save event.
$GLOBALS['wpdb']->update(
$GLOBALS['wpdb']->posts,
array(
'post_modified' => current_time( 'mysql' ),
'post_modified_gmt' => current_time( 'mysql', 1 ),
),
array(
'ID' => $product->get_id(),
)
);
clean_post_cache( $product->get_id() );
}
$this->update_post_meta( $product );