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.
Использование
$DataRegenerator = new DataRegenerator(); $DataRegenerator->do_regeneration_step( ?int $step_size, $use_optimized_db_access );
- ?int $step_size **
- -
По умолчанию: null - $use_optimized_db_access(true|false)
- Use direct database access for data retrieval if possible.
По умолчанию: false
Код DataRegenerator::do_regeneration_step() DataRegenerator::do regeneration step WC 9.3.3
public function do_regeneration_step( ?int $step_size = null, bool $use_optimized_db_access = false ) { /** * 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', $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 ( ! is_array( $product_ids ) || empty( $product_ids ) ) { return false; } $this->last_regeneration_step_failed = false; foreach ( $product_ids as $id ) { $this->data_store->create_data_for_product( $id, $use_optimized_db_access ); $this->last_regeneration_step_failed = $this->last_regeneration_step_failed || $this->data_store->get_last_create_operation_failed(); } $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; }