Search custom post type posts only by meta fields?

This might work, not tested though.
First add this to join the postmeta table:

add_filter( 'posts_join', 'search_filters_join', 501, 2 );

function search_filters_join( $join, $query ) {
    global $wpdb;

    if ( empty( $query->query_vars[ 'post_type' ] ) || $query->query_vars[ 'post_type' ] !== 'product' ) {
        return $join; // skip processing
    }

    if ( ($this->is_ajax_search() || $this->is_search_page()) && !is_admin() ) {

            $join .= " INNER JOIN $wpdb->postmeta AS customsearch ON ( $wpdb->posts.ID = customsearch.post_id )";
    }


    return $join;
}

Then modify your $search-variable in the foreach-loop as to include the following (this example shows _sku, just add on _author to another OR section if you want to search for that as well):

$search .= "{$searchand} (($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR (customsearch.meta_key='_sku' AND customsearch.meta_value LIKE '{$n}{$term}{$n}'))";

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)