As per WordPress Codex for the function
get_term_by( $field, $value, $taxonomy, $output, $filter );
If
$value
does not exist, the return value will befalse
. If$taxonomy
exists and$field
and$value
combinations exist, the Term will be returned.
So, you need to check the value of $name
in your code
$term = get_term_by('name', $name, 'product_cat');
$markup['brand'] = $term ;