Automattic\WooCommerce\Internal\CLI\Migrator\Lib

ImportSession::get_frontloading_stubspublicWC 1.0

Method of the class: ImportSession{}

No Hooks.

Returns

null. Nothing (null).

Usage

$ImportSession = new ImportSession();
$ImportSession->get_frontloading_stubs( $options );
$options
.
Default: array()

ImportSession::get_frontloading_stubs() code WC 10.7.0

public function get_frontloading_stubs( $options = array() ) {
	$query = new WP_Query(
		array(
			'post_type'      => 'frontloading_stub',
			'post_status'    => 'any',
			'post_parent'    => $this->post_id,
			'posts_per_page' => $options['per_page'] ?? 25,
			'paged'          => $options['page'] ?? 1,
			'orderby'        => array(
				'post_status' => array(
					self::FRONTLOAD_STATUS_ERROR             => 0,
					self::FRONTLOAD_STATUS_AWAITING_DOWNLOAD => 1,
					'any'                                    => 2,
				),
				'ID'          => 'ASC',
			),
		)
	);

	if ( ! $query->have_posts() ) {
		return array();
	}

	$posts = $query->posts;
	$ids   = array_map(
		function ( $post ) {
			return $post->ID;
		},
		$posts
	);
	update_meta_cache( 'post', $ids );
	foreach ( $posts as $post ) {
		$post->meta = get_all_post_meta_flat( $post->ID );
	}

	return $posts;
}