Hello,
I’m trying to include product attribute in the search query but with no luck.
I placed this code in functions.php:
add_filter('etheme_ajax_search_products_query', function ($args) {
$term = get_term_by('name', $args['s'], 'pa_brand-identifier');
$brand_id_args = array(
'taxonomy' => 'pa_brand-identifier',
'operator' => 'IN',
);
if ($term) {
$brand_id_args['terms'] = array($term->term_id);
array_push($args['tax_query'], $brand_id_args);
$args['tax_query']['relation'] = 'OR';
}
return $args;
});
Note: I tried with the slug field as well.
Am I doing something wrong?
Regards