Automattic\WooCommerce\Internal\CLI\Migrator\Core
ProductsController::simulate_stats_increment
Simulate incrementing stats by using reflection to access private properties. This ensures dry-run stats match what the real import would show.
Метод класса: ProductsController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->simulate_stats_increment( $stat_key ): void;
- $stat_key(строка) (обязательный)
- The stat key to increment.
Код ProductsController::simulate_stats_increment() ProductsController::simulate stats increment WC 10.8.1
private function simulate_stats_increment( string $stat_key ): void {
try {
$reflection = new \ReflectionClass( $this->product_importer );
$stats_property = $reflection->getProperty( 'import_stats' );
$stats_property->setAccessible( true );
$current_stats = $stats_property->getValue( $this->product_importer );
if ( isset( $current_stats[ $stat_key ] ) ) {
++$current_stats[ $stat_key ];
$stats_property->setValue( $this->product_importer, $current_stats );
}
} catch ( \ReflectionException $e ) {
wc_get_logger()->warning(
"DRY RUN: Could not update import stats for '{$stat_key}': " . $e->getMessage(),
array( 'source' => 'wc-migrator' )
);
}
}