Automattic\WooCommerce\DataBase\Migrations\CustomOrderTable

CLIRunner::normalize_raw_meta_data()privateWC 1.0

Helper method to normalize response from meta queries into order_id > meta_key > meta_values.

Method of the class: CLIRunner{}

No Hooks.

Return

Array. Normalized data.

Usage

// private - for code of main (parent) class only
$result = $this->normalize_raw_meta_data( $data ) : array;
$data(array) (required)
Data fetched from meta queries.

CLIRunner::normalize_raw_meta_data() code WC 8.6.1

private function normalize_raw_meta_data( array $data ) : array {
	$clubbed_data = array();
	foreach ( $data as $row ) {
		if ( ! isset( $clubbed_data[ $row['entity_id'] ] ) ) {
			$clubbed_data[ $row['entity_id'] ] = array();
		}
		if ( ! isset( $clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ] ) ) {
			$clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ] = array(); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Not a meta query.
		}
		$clubbed_data[ $row['entity_id'] ][ $row['meta_key'] ][] = $row['meta_value'];
	}
	return $clubbed_data;
}