WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API\Reports\Variations\Stats

Segmenter::get_product_related_intervals_segments() protected WC 1.0

Calculate segments for intervals where the segmenting property is bound to product (e.g. category, product_id, variation_id).

{} It's a method of the class: Segmenter{}

No Hooks.

Return

Array. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_product_related_intervals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $intervals_query, $unique_orders_table );
$segmenting_selections(array) (required)
SELECT part of segmenting SQL query--one for 'product_level' and one for 'order_level'.
$segmenting_from(string) (required)
FROM part of segmenting SQL query.
$segmenting_where(string) (required)
WHERE part of segmenting SQL query.
$segmenting_groupby(string) (required)
GROUP BY part of segmenting SQL query.
$segmenting_dimension_name(string) (required)
Name of the segmenting dimension.
$table_name(string) (required)
Name of SQL table which is the stats table for orders.
$intervals_query(array) (required)
Array of SQL clauses for intervals query.
$unique_orders_table(string) (required)
Name of temporary SQL table that holds unique orders.

Code of Segmenter::get_product_related_intervals_segments() WC 5.3.0

<?php
protected function get_product_related_intervals_segments( $segmenting_selections, $segmenting_from, $segmenting_where, $segmenting_groupby, $segmenting_dimension_name, $table_name, $intervals_query, $unique_orders_table ) {
	global $wpdb;

	$product_segmenting_table = $wpdb->prefix . 'wc_order_product_lookup';

	// LIMIT offset, rowcount needs to be updated to a multiple of the number of segments.
	preg_match( '/LIMIT (\d+)\s?,\s?(\d+)/', $intervals_query['limit'], $limit_parts );
	$segment_count    = count( $this->get_all_segments() );
	$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(
		"SELECT
					{$intervals_query['select_clause']} AS time_interval,
					$segmenting_groupby AS $segmenting_dimension_name
					{$segmenting_selections['product_level']}
				FROM
					$table_name
					$segmenting_from
					{$intervals_query['from_clause']}
				WHERE
					1=1
					{$intervals_query['where_time_clause']}
					{$intervals_query['where_clause']}
					$segmenting_where
				GROUP BY
					time_interval, $segmenting_groupby
				$segmenting_limit",
		ARRAY_A
	); // WPCS: cache ok, DB call ok, unprepared SQL ok.

	$intervals_segments = $this->merge_segment_intervals_results( $segmenting_dimension_name, $segments_products, array() );
	return $intervals_segments;
}