Automattic\WooCommerce\Database\Migrations

MetaToMetaTableMigrator::process_migration_batch_for_ids_core()protectedWC 1.0

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

Method of the class: MetaToMetaTableMigrator{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->process_migration_batch_for_ids_core( $entity_ids ): void;
$entity_ids(array) (required)
Ids of entities ro migrate.

MetaToMetaTableMigrator::process_migration_batch_for_ids_core() code WC 7.1.0

protected function process_migration_batch_for_ids_core( array $entity_ids ): void {
	$to_migrate = $this->fetch_data_for_migration_for_ids( $entity_ids );
	if ( empty( $to_migrate ) ) {
		return;
	}

	$already_migrated = $this->get_already_migrated_records( array_keys( $to_migrate ) );

	$data      = $this->classify_update_insert_records( $to_migrate, $already_migrated );
	$to_insert = $data[0];
	$to_update = $data[1];

	if ( ! empty( $to_insert ) ) {
		$insert_queries       = $this->generate_insert_sql_for_batch( $to_insert );
		$processed_rows_count = $this->db_query( $insert_queries );
		$this->maybe_add_insert_or_update_error( 'insert', $processed_rows_count );
	}

	if ( ! empty( $to_update ) ) {
		$update_queries       = $this->generate_update_sql_for_batch( $to_update );
		$processed_rows_count = $this->db_query( $update_queries );
		$this->maybe_add_insert_or_update_error( 'update', $processed_rows_count );
	}
}