Automattic\WooCommerce\Internal\CLI\Migrator\Core

ProductsController::create_new_sessionprivateWC 1.0

Create a new import session.

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

Хуков нет.

Возвращает

ImportSession|null. New session instance or null on error.

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

// private - только в коде основоного (родительского) класса
$result = $this->create_new_session( $parsed_args ): ?ImportSession;
$parsed_args(массив) (обязательный)
Parsed command arguments.

Код ProductsController::create_new_session() WC 11.1.0

private function create_new_session( array $parsed_args ): ?ImportSession {
	try {
		$session = ImportSession::create(
			array(
				'data_source' => $parsed_args['platform'],
				'file_name'   => sprintf(
					'%s Migration - %s',
					ucfirst( $parsed_args['platform'] ),
					current_time( 'mysql' )
				),
			)
		);

		$session->set_original_arguments( $parsed_args );

		return $session;

	} catch ( Exception $e ) {
		WP_CLI::error( sprintf( 'Failed to create migration session: %s', $e->getMessage() ) );
		return null;
	}
}