Automattic\WooCommerce\Internal\CLI\Migrator\Core
ProductsController::display_product_progress
Display progress indicator for individual product imports.
Method of the class: ProductsController{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ProductsController = new ProductsController(); $ProductsController->display_product_progress( $current_index, $total_count, $product_name, ?array $result ): void;
- $current_index(int) (required)
- Current product index (1-based).
- $total_count(int) (required)
- Total number of products in batch.
- $product_name(string) (required)
- Name of the product being processed.
- ?array $result(required)
- .
ProductsController::display_product_progress() ProductsController::display product progress code WC 10.5.0
public function display_product_progress( int $current_index, int $total_count, string $product_name, ?array $result ): void {
if ( null === $result ) {
return;
}
$display_name = strlen( $product_name ) > 40 ? substr( $product_name, 0, 37 ) . '...' : $product_name;
$status_char = '✓';
$status_color = '%G';
if ( 'error' === $result['status'] ) {
$status_char = '✗';
$status_color = '%R';
} elseif ( 'success' === $result['status'] && 'skipped' === $result['action'] ) {
$status_char = '−';
$status_color = '%Y';
}
$progress = sprintf( '[%d/%d]', $current_index, $total_count );
if ( 1 === $current_index ) {
WP_CLI::line( '' );
}
WP_CLI::line(
WP_CLI::colorize(
sprintf( '%s%s%s %s %s', $status_color, $status_char, '%n', $progress, $display_name )
)
);
}