Prime term cache before read

This commit is contained in:
Mike Jolley 2017-06-21 17:09:39 +01:00
parent 5ffff712e7
commit e06aa6f60a
2 changed files with 7 additions and 0 deletions

View File

@ -283,6 +283,9 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$product->set_average_rating( $average_rating );
}
// Prime the cache.
update_object_term_cache( $id, 'product' );
$product->set_props( array(
'sku' => get_post_meta( $id, '_sku', true ),
'regular_price' => get_post_meta( $id, '_regular_price', true ),

View File

@ -261,6 +261,10 @@ class WC_Product_Variation_Data_Store_CPT extends WC_Product_Data_Store_CPT impl
*/
protected function read_product_data( &$product ) {
$id = $product->get_id();
// Prime the cache.
update_object_term_cache( $id, 'product_variation' );
$product->set_props( array(
'description' => get_post_meta( $id, '_variation_description', true ),
'regular_price' => get_post_meta( $id, '_regular_price', true ),