Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog
AsyncGenerator::get_status
Returns the current feed generation status. Initiates one if not already running.
Метод класса: AsyncGenerator{}
Хуков нет.
Возвращает
Массив. The feed generation status.
Использование
$AsyncGenerator = new AsyncGenerator(); $AsyncGenerator->get_status( ?array $args ): array;
- ?array $args
- .
По умолчанию:null
Список изменений
| С версии 10.5.0 | Введена. |
Код AsyncGenerator::get_status() AsyncGenerator::get status WC 10.5.2
public function get_status( ?array $args = null ): array {
// Determine the option key based on the integration ID and arguments.
$option_key = $this->get_option_key( $args );
$status = get_option( $option_key );
// For existing jobs, make sure that everything in the status makes sense.
if ( is_array( $status ) && ! $this->validate_status( $status ) ) {
$status = false;
}
// If the status is an array, it means that there is nothing to schedule in this method.
if ( is_array( $status ) ) {
return $status;
}
// Clear all previous actions to avoid race conditions.
as_unschedule_all_actions( self::FEED_GENERATION_ACTION, array( $option_key ), 'woo-product-feed' ); // @phpstan-ignore function.notFound
$status = array(
'scheduled_at' => time(),
'completed_at' => null,
'state' => self::STATE_SCHEDULED,
'progress' => 0,
'processed' => 0,
'total' => -1,
'args' => $args ?? array(),
);
update_option(
$option_key,
$status
);
// Start an immediate async action to generate the feed.
// @phpstan-ignore-next-line function.notFound -- Action Scheduler.
as_enqueue_async_action(
self::FEED_GENERATION_ACTION,
array( $option_key ),
'woo-product-feed',
true,
1
);
// Manually force an async request to be dispatched to process the action immediately.
if ( class_exists( ActionScheduler_AsyncRequest_QueueRunner::class ) && class_exists( ActionScheduler_Store::class ) ) {
$store = ActionScheduler_Store::instance();
$async_request = new ActionScheduler_AsyncRequest_QueueRunner( $store );
$async_request->dispatch();
}
return $status;
}