Automattic\WooCommerce\Internal\ProductFeed\Feed

ProductWalker::from_integrationpublic staticWC 10.5.0

Creates a new instance of the ProductWalker class based on an integration.

The walker will mostly be set up based on the integration. The feed is provided externally, as it might be based on the context (CLI, REST, Action Scheduler, etc.).

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

Хуки из метода

Возвращает

self. The ProductWalker instance.

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

$result = ProductWalker::from_integration( $integration, $feed ): self;
$integration(IntegrationInterface) (обязательный)
The integration.
$feed(FeedInterface) (обязательный)
The feed.

Список изменений

С версии 10.5.0 Введена.

Код ProductWalker::from_integration() WC 10.5.2

public static function from_integration(
	IntegrationInterface $integration,
	FeedInterface $feed
): self {
	$query_args = array_merge(
		array(
			'status' => array( 'publish' ),
			'return' => 'objects',
		),
		$integration->get_product_feed_query_args()
	);

	/**
	 * Allows the base arguments for querying products for product feeds to be changed.
	 *
	 * Variable products are not included by default, as their variations will be included.
	 *
	 * @since 10.5.0
	 *
	 * @param array                $query_args The arguments to pass to wc_get_products().
	 * @param IntegrationInterface $integration The integration that the query belongs to.
	 * @return array
	 */
	$query_args = apply_filters(
		'woocommerce_product_feed_args',
		$query_args,
		$integration
	);

	$instance = new self(
		$integration->get_product_mapper(),
		$integration->get_feed_validator(),
		$feed,
		wc_get_container()->get( ProductLoader::class ),
		wc_get_container()->get( MemoryManager::class ),
		$query_args
	);

	return $instance;
}