Automattic\WooCommerce\Internal\ProductFeed\Feed
ProductWalker::iterate
Iterates through a batch of products.
Метод класса: ProductWalker{}
Хуков нет.
Возвращает
\stdClass. The result of the query with properties: products, total, max_num_pages.
Использование
// private - только в коде основоного (родительского) класса $result = $this->iterate( $args, $page, $limit ): \stdClass;
- $args(массив)
- The arguments to pass to wc_get_products().
По умолчанию:array() - $page(int)
- The page number to iterate through.
По умолчанию:1 - $limit(int)
- The maximum number of products to iterate through.
По умолчанию:100
Код ProductWalker::iterate() ProductWalker::iterate WC 10.5.2
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;
}