Modify search form with plugin

Here’s an alternative way to only make the product post type searchable, from a plugin code:

<?php
/** Plugin Name: Product Search Only **/

add_filter( 'register_post_type_args', function( $args, $post_type )
{
    $args['exclude_from_search'] = true;

    if( 'product' === $post_type && (bool) $args['public'] )
        $args['exclude_from_search'] = false;

    return $args;
}, 999, 2 );

Here we modify the post type registration, by setting the exclude_from_search to true, for all post types, except the public product post type. If needed you can adjust the late priority.