Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories
Synchronize::get_next_set_of_downloadable_products()
Queries for the next batch of downloadable products, applying logic to ensure we only fetch those that actually have downloadable files (a downloadable product can be created that does not have downloadable files and/or downloadable files can be removed from existing downloadable products).
Method of the class: Synchronize{}
No Hooks.
Return
Array
.
Usage
// private - for code of main (parent) class only $result = $this->get_next_set_of_downloadable_products(): array;
Synchronize::get_next_set_of_downloadable_products() Synchronize::get next set of downloadable products code WC 9.8.2
private function get_next_set_of_downloadable_products(): array { $query_filter = function ( array $query ): array { $query['meta_query'][] = array( 'key' => '_downloadable_files', 'compare' => 'EXISTS', ); return $query; }; $page = (int) get_option( self::SYNC_TASK_PAGE, 1 ); add_filter( 'woocommerce_product_data_store_cpt_get_products_query', $query_filter ); $products = wc_get_products( array( 'limit' => self::SYNC_TASK_BATCH_SIZE, 'page' => $page, 'paginate' => true, ) ); remove_filter( 'woocommerce_product_data_store_cpt_get_products_query', $query_filter ); $progress = $products->max_num_pages > 0 ? (int) ( ( $page / $products->max_num_pages ) * 100 ) : 1; update_option( self::SYNC_TASK_PAGE, $page + 1 ); update_option( self::SYNC_TASK_PROGRESS, $progress ); return $products->products; }