How to exclude specific post_type from default search?

If you want to exclude the “product” post type (= WooCommerce products) from all front-end searches on your site, you can use this code:

function my_adjust_post_type_args( $args, $post_type ) {
    if ( 'product' === $post_type ) {
        $args['exclude_from_search'] = true;
    }

    return $args;
}

add_filter( 'register_post_type_args', 'my_adjust_post_type_args', 10, 2 );

It modifies the “exclude_from_search” argument when the “product” post type is registered. See the docs for the register_post_type() function for more information.