Automattic\WooCommerce\Internal\ProductFeed\Feed
ProductWalker::iterate
Iterates through a batch of products.
Method of the class: ProductWalker{}
No Hooks.
Returns
\stdClass. The result of the query with properties: products, total, max_num_pages.
Usage
// private - for code of main (parent) class only $result = $this->iterate( $args, $page, $limit ): \stdClass;
- $args(array)
- The arguments to pass to wc_get_products().
Default:array() - $page(int)
- The page number to iterate through.
Default:1 - $limit(int)
- The maximum number of products to iterate through.
Default:100
ProductWalker::iterate() ProductWalker::iterate code WC 10.8.1
private function iterate( array $args = array(), int $page = 1, int $limit = 100 ): \stdClass {
/**
* Result is always stdClass when paginate=true.
*
* @var \stdClass $result
*/
$result = $this->product_loader->get_products(
array_merge(
$args,
array(
'page' => $page,
'limit' => $limit,
'paginate' => true,
)
)
);
foreach ( $result->products as $product ) {
$mapped_data = $this->mapper->map_product( $product );
if ( ! empty( $this->validator->validate_entry( $mapped_data, $product ) ) ) {
continue;
}
$this->feed->add_entry( $mapped_data );
}
return $result;
}