wc_update_product_lookup_tables_rating_count_batch()
Populate a batch of rating count lookup table data for products.
No Hooks.
Return
null
. Nothing (null).
Usage
wc_update_product_lookup_tables_rating_count_batch( $offset, $limit );
- $offset(array)
- Offset to query.
- $limit(array)
- Limit to query.
Changelog
Since 3.6.2 | Introduced. |
wc_update_product_lookup_tables_rating_count_batch() wc update product lookup tables rating count batch code WC 9.3.1
function wc_update_product_lookup_tables_rating_count_batch( $offset = 0, $limit = 0 ) { global $wpdb; if ( ! $limit ) { return; } $rating_count_rows = $wpdb->get_results( $wpdb->prepare( " SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_wc_rating_count' AND meta_value != '' AND meta_value != 'a:0:{}' ORDER BY post_id ASC LIMIT %d, %d ", $offset, $limit ), ARRAY_A ); if ( $rating_count_rows ) { wc_update_product_lookup_tables_rating_count( $rating_count_rows ); WC()->queue()->schedule_single( time() + 1, 'wc_update_product_lookup_tables_rating_count_batch', array( 'offset' => $offset + $limit, 'limit' => $limit, ), 'wc_update_product_lookup_tables' ); } }