Automattic\WooCommerce\Database\Migrations

MetaToCustomTableMigrator::process_migration_batch_for_ids_core()protectedWC 1.0

Migrate a batch of entities from the posts table to the corresponding table.

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

Хуков нет.

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->process_migration_batch_for_ids_core( $entity_ids ): void;
$entity_ids(массив) (обязательный)
Ids of entities to migrate.

Код MetaToCustomTableMigrator::process_migration_batch_for_ids_core() WC 7.5.0

protected function process_migration_batch_for_ids_core( array $entity_ids ): void {
	$data = $this->fetch_data_for_migration_for_ids( $entity_ids );

	foreach ( $data['errors'] as $entity_id => $errors ) {
		foreach ( $errors as $column_name => $error_message ) {
			$this->add_error( "Error importing data for post with id $entity_id: column $column_name: $error_message" );
		}
	}

	if ( count( $data['data'] ) === 0 ) {
		return;
	}

	$entity_ids       = array_keys( $data['data'] );
	$existing_records = $this->get_already_existing_records( $entity_ids );

	$to_insert = array_diff_key( $data['data'], $existing_records );
	$this->process_insert_batch( $to_insert );

	$existing_records = array_filter(
		$existing_records,
		function( $record_data ) {
			return '1' === $record_data->modified;
		}
	);
	$to_update        = array_intersect_key( $data['data'], $existing_records );
	$this->process_update_batch( $to_update, $existing_records );
}