Automattic\WooCommerce\Internal\CLI\Migrator\Core
ProductsController::log_batch_results
Log batch import results.
Method of the class: ProductsController{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->log_batch_results( $batch_results ): void;
- $batch_results(array) (required)
- Results from batch import.
ProductsController::log_batch_results() ProductsController::log batch results code WC 10.7.0
private function log_batch_results( array $batch_results ): void {
$stats = $batch_results['stats'];
// Only log failures and errors when verbose flag is set.
if ( $this->parsed_args['verbose'] && $stats['failed'] > 0 ) {
WP_CLI::warning( sprintf( '%d products failed to import', $stats['failed'] ) );
// Log first few errors for debugging.
$error_count = 0;
foreach ( $batch_results['results'] as $result ) {
if ( 'error' === $result['status'] && $error_count < 3 ) {
WP_CLI::warning( sprintf( 'Import error: %s', $result['message'] ) );
++$error_count;
}
}
}
// Only log skipped products if there are many and verbose is enabled.
if ( $this->parsed_args['verbose'] && $stats['skipped'] > 5 ) {
WP_CLI::log( sprintf( 'Skipped %d existing products', $stats['skipped'] ) );
}
}