Automattic\WooCommerce\Internal\Admin\Schedulers

ImportScheduler::import_batch()public staticWC 1.0

Imports a batch of items to update.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = ImportScheduler::import_batch( $batch_number, $days, $skip_existing );
$batch_number(int) (обязательный)
Batch number to import (essentially a query page number).
$days(int|true|false) (обязательный)
Number of days to import.
$skip_existing(true|false) (обязательный)
Skip exisiting records.

Код ImportScheduler::import_batch() WC 8.7.0

public static function import_batch( $batch_number, $days, $skip_existing ) {
	$batch_size = static::get_batch_size( 'import' );

	$properties = array(
		'batch_number' => $batch_number,
		'batch_size'   => $batch_size,
		'type'         => static::$name,
	);
	wc_admin_record_tracks_event( 'import_job_start', $properties );

	// When we are skipping already imported items, the table of items to import gets smaller in
	// every batch, so we want to always import the first page.
	$page  = $skip_existing ? 1 : $batch_number;
	$items = static::get_items( $batch_size, $page, $days, $skip_existing );

	foreach ( $items->ids as $id ) {
		static::import( $id );
	}

	$import_stats                              = get_option( self::IMPORT_STATS_OPTION, array() );
	$imported_count                            = absint( $import_stats[ static::$name ]['imported'] ) + count( $items->ids );
	$import_stats[ static::$name ]['imported'] = $imported_count;
	update_option( self::IMPORT_STATS_OPTION, $import_stats );

	$properties['imported_count'] = $imported_count;

	wc_admin_record_tracks_event( 'import_job_complete', $properties );
}