WC_REST_Products_Controller::get_objects │ protected │ WC 1.0

Get objects.

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

Хуков нет.

Возвращает

array.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_objects( $query_args );
$query_args(массив) (обязательный)
Query args.

Код WC_REST_Products_Controller::get_objects() WC 11.2.1

protected function get_objects( $query_args ) {
	$add_search_criteria = $this->search_sku_arg_value || $this->search_name_or_sku_tokens || $this->search_fields_tokens;

	// Add filters for search criteria in product postmeta via the lookup table.
	if ( $add_search_criteria ) {
		add_filter( 'posts_join', array( $this, 'add_search_criteria_to_wp_query_join' ) );
		add_filter( 'posts_where', array( $this, 'add_search_criteria_to_wp_query_where' ) );
	}

	// Add filters for excluding product statuses.
	if ( ! empty( $this->exclude_status ) ) {
		add_filter( 'posts_where', array( $this, 'exclude_product_statuses' ) );
	}

	$result = parent::get_objects( $query_args );

	// Remove filters for search criteria in product postmeta via the lookup table.
	if ( $add_search_criteria ) {
		remove_filter( 'posts_join', array( $this, 'add_search_criteria_to_wp_query_join' ) );
		remove_filter( 'posts_where', array( $this, 'add_search_criteria_to_wp_query_where' ) );

		$this->search_sku_arg_value      = '';
		$this->search_name_or_sku_tokens = null;
		$this->search_fields_tokens      = null;
	}

	// Remove filters for excluding product statuses.
	if ( ! empty( $this->exclude_status ) ) {
		remove_filter( 'posts_where', array( $this, 'exclude_product_statuses' ) );

		$this->exclude_status = array();
	}

	// Batch-prime image attachment caches for the whole collection, rather than once per
	// product when get_images() runs during serialization.
	if ( ! empty( $result['objects'] ) ) {
		wc_get_container()->get( ProductUtil::class )->prime_image_caches( $result['objects'] );
	}

	return $result;
}