Automattic\WooCommerce\Database\Migrations\CustomOrderTable
CLIRunner::normalize_raw_meta_data()
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() CLIRunner::normalize raw meta data code WC 9.7.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; }