Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog
AsyncGenerator::get_status
Returns the current feed generation status. Initiates one if not already running.
Method of the class: AsyncGenerator{}
No Hooks.
Returns
Array. The feed generation status.
Usage
$AsyncGenerator = new AsyncGenerator(); $AsyncGenerator->get_status( ?array $args ): array;
- ?array $args
- .
Default:null
Changelog
| Since 10.5.0 | Introduced. |
AsyncGenerator::get_status() AsyncGenerator::get status code WC 10.8.1
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' );
$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.
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;
}