Automattic\WooCommerce\Internal\ProductAttributesLookup
CLIRunner::regenerate_for_product_core
Core method for the "regenerate_for_product" command.
Method of the class: CLIRunner{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->regenerate_for_product_core( $args, $assoc_args );
- $args(array)
- Positional arguments passed to the command.
Default: array() - $assoc_args(array)
- Associative arguments (options) passed to the command.
Default: array()
CLIRunner::regenerate_for_product_core() CLIRunner::regenerate for product core code WC 10.3.3
private function regenerate_for_product_core( array $args = array(), array $assoc_args = array() ) {
$product_id = current( $args );
$this->data_regenerator->check_can_do_lookup_table_regeneration( $product_id );
$use_db_optimization = ! array_key_exists( 'disable-db-optimization', $assoc_args );
$this->check_can_use_db_optimization( $use_db_optimization );
$start_time = microtime( true );
$this->lookup_data_store->create_data_for_product( $product_id, $use_db_optimization );
if ( $this->lookup_data_store->get_last_create_operation_failed() ) {
$this->error( "Lookup data regeneration failed.\nSee the WooCommerce logs (source is %9palt-updates%n) for details." );
} else {
$total_time = microtime( true ) - $start_time;
WP_CLI::success( sprintf( 'Attributes lookup data for product %d regenerated in %f seconds.', $product_id, $total_time ) );
}
}