Automattic\WooCommerce\Internal\ProductFeed\Integrations\POSCatalog

ProductMapper::get_products_requestprotectedWC 1.0

Get the REST request instance for products.

Method of the class: ProductMapper{}

No Hooks.

Returns

WP_REST_Request. mixed>>

Usage

// protected - for code of main (parent) or child class
$result = $this->get_products_request(): WP_REST_Request;

ProductMapper::get_products_request() code WC 10.7.0

protected function get_products_request(): WP_REST_Request {
	if ( null === $this->products_request ) {
		/**
		 * Type hint for PHPStan generics.
		 *
		 * @var WP_REST_Request<array<string, mixed>> $request
		 * */
		$request                = new WP_REST_Request( 'GET' );
		$this->products_request = $request;
		$this->products_request->set_param( 'context', 'view' );

		if ( null !== $this->fields ) {
			$this->products_request->set_param( '_fields', $this->fields );
		}
	}

	return $this->products_request;
}

/**
 * Get the REST request instance for variations.
 *
 * @return WP_REST_Request<array<string, mixed>>
 */
protected function get_variations_request(): WP_REST_Request {
	if ( null === $this->variations_request ) {
		/**
		 * Type hint for PHPStan generics.
		 *
		 * @var WP_REST_Request<array<string, mixed>> $request
		 */
		$request                  = new WP_REST_Request( 'GET' );
		$this->variations_request = $request;
		$this->variations_request->set_param( 'context', 'view' );

		if ( null !== $this->variation_fields ) {
			$this->variations_request->set_param( '_fields', $this->variation_fields );
		}
	}

	return $this->variations_request;
}
}