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.).

Method of the class: ProductWalker{}

Hooks from the method

Returns

self. The ProductWalker instance.

Usage

$result = ProductWalker::from_integration( $integration, $feed ): self;
$integration(IntegrationInterface) (required)
The integration.
$feed(FeedInterface) (required)
The feed.

Changelog

Since 10.5.0 Introduced.

ProductWalker::from_integration() code WC 10.7.0

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;
}