Automattic\WooCommerce\Database\Migrations

MetaToMetaTableMigrator::fetch_data_for_migration_for_ids()publicWC 1.0

Fetch data for migration.

Метод класса: MetaToMetaTableMigrator{}

Хуков нет.

Возвращает

Массив[]. Data, will of the form: array( 'id_1' => array( 'column1' => array( value1_1, value1_2...), 'column2' => array(value2_1, value2_2...), ...), ..., )

Использование

$MetaToMetaTableMigrator = new MetaToMetaTableMigrator();
$MetaToMetaTableMigrator->fetch_data_for_migration_for_ids( $entity_ids ): array;
$entity_ids(массив) (обязательный)
Array of IDs to fetch data for.

Код MetaToMetaTableMigrator::fetch_data_for_migration_for_ids() WC 9.3.3

public function fetch_data_for_migration_for_ids( array $entity_ids ): array {
	if ( empty( $entity_ids ) ) {
		return array();
	}

	$meta_query = $this->build_meta_table_query( $entity_ids );

	$meta_data_rows = $this->db_get_results( $meta_query );
	if ( ! is_array( $meta_data_rows ) || empty( $meta_data_rows ) ) {
		return array();
	}

	foreach ( $meta_data_rows as $migrate_row ) {
		if ( ! isset( $to_migrate[ $migrate_row->entity_id ] ) ) {
			$to_migrate[ $migrate_row->entity_id ] = array();
		}

		if ( ! isset( $to_migrate[ $migrate_row->entity_id ][ $migrate_row->meta_key ] ) ) {
			// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
			$to_migrate[ $migrate_row->entity_id ][ $migrate_row->meta_key ] = array();
		}

		$to_migrate[ $migrate_row->entity_id ][ $migrate_row->meta_key ][] = $migrate_row->meta_value;
	}

	return $to_migrate;
}