Looks like I found the solution for you. Please use following code snippet
add_filter( 'aws_excerpt_search_result', 'aws_excerpt_search_result', 10, 3 );
function aws_excerpt_search_result( $excerpt, $post_id, $product ) {
$terms = get_the_terms( $post_id, 'product_cat' );
$terms_arr = array();
if ( ! is_wp_error( $terms ) && !empty( $terms ) ) {
foreach ( $terms as $term ) {
$terms_arr[] = $term->name;
}
$term_string = implode(',', $terms_arr);
if ( $term_string ) {
$excerpt .= '<br>' . '<span style="padding: 6px 0 6px;display: block;">' . $term_string . '</span>';
}
}
return $excerpt;
}
add_filter( 'aws_search_tax_results', 'my_aws_search_tax_results', 10, 2 );
function my_aws_search_tax_results( $results, $taxonomy ) {
if ( isset( $results['product_cat'] ) ) {
foreach( $results['product_cat'] as $key => $cat_item ) {
$term = get_term( $cat_item['id'], 'product_cat' );
if ( $term && $term->parent ) {
$termParent = get_term($term->parent, 'product_cat');
if ( $termParent ) {
$results['product_cat'][$key]['excerpt'] .= $termParent->name;
}
}
}
}
return $results;
}
You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Also after adding this code you will need to go to the plugin settings page and click the ‘Clear cache’ button.