Search Query

<?php

add_filter( 'pre_get_posts', function( $query ) {
    if ( $query->is_main_query() && $query->is_search() ) {
        $query->set( 'post_type', [ 'post', 'product'] );
    }
} );