WC_Product_CSV_Importer_Controller::dispatch_ajax_cleanup │ private static │ WC 1.0

Run one bounded pass of the post-import cleanup and tell the client where to resume.

The cursor only ever skips placeholders forward, and the queries it feeds match nothing but the importer's own temporary products, so it needs no server-side state of its own.

Method of the class: WC_Product_CSV_Importer_Controller{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = WC_Product_CSV_Importer_Controller::dispatch_ajax_cleanup( $cursor ): void;
$cursor(int) (required)
Highest placeholder ID earlier cleanup requests have examined.

WC_Product_CSV_Importer_Controller::dispatch_ajax_cleanup() code WC 11.2.1

private static function dispatch_ajax_cleanup( int $cursor ): void {
	$next_cursor = self::cleanup_after_import( $cursor );

	$response = array(
		'position'            => null === $next_cursor ? 'done' : self::CLEANUP_POSITION_PREFIX . $next_cursor,
		'percentage'          => 100,
		'imported'            => 0,
		'imported_variations' => 0,
		'failed'              => 0,
		'updated'             => 0,
		'skipped'             => 0,
	);

	if ( null === $next_cursor ) {
		$response['url'] = add_query_arg( array( '_wpnonce' => wp_create_nonce( 'woocommerce-csv-importer' ) ), admin_url( 'edit.php?post_type=product&page=product_importer&step=done' ) );
	}

	wp_send_json_success( $response );
}