How to get only post=’product’

If I understand you, what you are doing is wildly complicated. All you should need is a simple pre_get_posts filter:

add_filter( 'pre_get_posts', 'modified_pre_get_posts' ); 
function modified_pre_get_posts( $query ) { 
  if ( $query->is_search() ) { 
    $query->set( 'post_type', 'product' ); 
  } 
  return $query; 
}

Plus your filter that adds DISTINCT.

post_type is a query parameter rolled into Core. Passing an URL such as localhost/wp/?s=D34&post_type=product should by default limit your queries to the single named post type. You shouldn’t have to do anything special to make that work. Your filter may in fact be causing trouble.