From 0d664fdd87bd1124289ee67a30e6da4921df5c10 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 10 Oct 2019 14:15:25 -0300 Subject: [PATCH] use category lookup id instead of term taxonomy id (https://github.com/woocommerce/woocommerce-admin/pull/3027) --- .../src/API/Reports/Products/Stats/Segmenter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce-admin/src/API/Reports/Products/Stats/Segmenter.php b/plugins/woocommerce-admin/src/API/Reports/Products/Stats/Segmenter.php index 5f4e57ca4f0..cb61c9356fc 100644 --- a/plugins/woocommerce-admin/src/API/Reports/Products/Stats/Segmenter.php +++ b/plugins/woocommerce-admin/src/API/Reports/Products/Stats/Segmenter.php @@ -104,7 +104,7 @@ class Segmenter extends ReportsSegmenter { $orig_offset = intval( $limit_parts[1] ); $orig_rowcount = intval( $limit_parts[2] ); $segmenting_limit = $wpdb->prepare( 'LIMIT %d, %d', $orig_offset * $segment_count, $orig_rowcount * $segment_count ); - + // Can't get all the numbers from one query, so split it into one query for product-level numbers and one for order-level numbers (which first need to have orders uniqued). // Product-level numbers. $segments_products = $wpdb->get_results( @@ -191,8 +191,8 @@ class Segmenter extends ReportsSegmenter { // Restrict our search space for category comparisons. if ( isset( $this->query_args['categories'] ) ) { - $category_ids = implode( ',', $this->get_all_segments() ); - $segmenting_where .= " AND wp_term_taxonomy.term_taxonomy_id IN ( $category_ids )"; + $category_ids = implode( ',', $this->get_all_segments() ); + $segmenting_where .= " AND {$wpdb->wc_category_lookup}.category_id IN ( $category_ids )"; } $segments = $this->get_product_related_segments( $type, $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $query_params, $unique_orders_table );