Automattic\WooCommerce\Database\Migrations
MetaToCustomTableMigrator::process_migration_data
Process migration data for a batch of entities.
Метод класса: MetaToCustomTableMigrator{}
Хуков нет.
Возвращает
Массив. Array of errors and exception if any.
Использование
$MetaToCustomTableMigrator = new MetaToCustomTableMigrator(); $MetaToCustomTableMigrator->process_migration_data( $data );
- $data(массив) (обязательный)
- Data to be migrated. Should be of the form: array(
'data'=> array( ... ) ) as returned by thefetch_sanitized_migration_datamethod.
Код MetaToCustomTableMigrator::process_migration_data() MetaToCustomTableMigrator::process migration data WC 10.7.0
public function process_migration_data( array $data ) {
$this->clear_errors();
$exception = null;
if ( ! isset( $data['data'] ) || ! is_array( $data['data'] ) || count( $data['data'] ) === 0 ) {
return array(
'errors' => $this->get_errors(),
'exception' => null,
);
}
try {
$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 );
$to_update = array_intersect_key( $data['data'], $existing_records );
$this->process_update_batch( $to_update, $existing_records );
} catch ( \Exception $e ) {
$exception = $e;
}
return array(
'errors' => $this->get_errors(),
'exception' => $exception,
);
}