WordPress – Copy product slugs from original language

If you need to replace product slugs in other language from the original you should try:

add_action( 'init', function() {
	if ( !empty( $_GET['update_product_slugs'] )) {
		$posts = get_posts( array (
			'post_type' => 'product',
			'numberposts' => -1
		) );
		foreach ( $posts as $post ) {
			$el_id = apply_filters( 'wpml_object_id', $post->ID, 'product', false, $_GET['update_product_slugs'] );
			if ( $el_id ) {
				$r[] = wp_update_post([
					'ID' => $el_id,
					'post_name' => $post->post_name
				]);
			}
		}
	}
});