Automattic\WooCommerce\Internal\ProductAttributesLookup
DataRegenerator::do_regeneration_step()
Perform one regeneration step: grabs a chunk of products and creates the appropriate entries for them in the lookup table.
Метод класса: DataRegenerator{}
Хуки из метода
Возвращает
true|false
. True if more steps need to be run, false otherwise.
Использование
// private - только в коде основоного (родительского) класса $result = $this->do_regeneration_step();
Код DataRegenerator::do_regeneration_step() DataRegenerator::do regeneration step WC 8.1.1
private function do_regeneration_step() { /** * Filter to alter the count of products that will be processed in each step of the product attributes lookup table regeneration process. * * @since 6.3 * @param int $count Default processing step size. */ $products_per_generation_step = apply_filters( 'woocommerce_attribute_lookup_regeneration_step_size', self::PRODUCTS_PER_GENERATION_STEP ); $products_already_processed = get_option( 'woocommerce_attribute_lookup_processed_count', 0 ); $product_ids = WC()->call_function( 'wc_get_products', array( 'limit' => $products_per_generation_step, 'offset' => $products_already_processed, 'orderby' => array( 'ID' => 'ASC', ), 'return' => 'ids', ) ); if ( ! $product_ids ) { return false; } foreach ( $product_ids as $id ) { $this->data_store->create_data_for_product( $id ); } $products_already_processed += count( $product_ids ); update_option( 'woocommerce_attribute_lookup_processed_count', $products_already_processed ); $last_product_id_to_process = get_option( 'woocommerce_attribute_lookup_last_product_id_to_process', PHP_INT_MAX ); return end( $product_ids ) < $last_product_id_to_process; }