Merge pull request #15740 from woocommerce/update/prime-term-caches

Update/prime term caches for product queries
This commit is contained in:
Claudiu Lodromanean 2017-06-22 08:18:55 -07:00 committed by GitHub
commit 5ebc4a4010
3 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,9 @@ class WC_Shortcodes {
ob_start();
if ( $products->have_posts() ) {
// Prime caches before grabbing objects.
update_post_caches( $products->posts, array( 'product', 'product_variation' ) );
?>
<?php do_action( "woocommerce_shortcode_before_{$loop_name}_loop", $atts ); ?>

View File

@ -1269,6 +1269,9 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$products = new WP_Query( $wp_query_args );
if ( 'objects' === $args['return'] ) {
// Prime caches before grabbing objects.
update_post_caches( $products->posts, array( 'product', 'product_variation' ) );
$return = array_filter( array_map( 'wc_get_product', $products->posts ) );
} else {
$return = $products->posts;

View File

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