I want to get product attirbute in the section below

I want to add product brand and weight which i have defined in attribute of product but it am using the

<?php
$weightvalues = get_the_terms( $product->id, 'pa_weight');

      foreach ( $weightvalues as $weightvalue ) {
       echo $weightvalue->name;
        } ?>

which i have used in the product page but its not working inthe code below.
What should i do?

<?php 
$title='';
                        if($show_title)
                        {
                            //$title = '<h3 class="ls-result-title"><a href="'.$product->get_permalink().'">'.$product->get_title().'</a></h3>';
                            $variation_label='';
                            if(get_post_type($pid)=='product_variation'){
                                $all_meta = get_post_meta( $pid );
                                foreach ( $all_meta as $name => $value ) {
                                    if ( ! strstr( $name, 'attribute_' ) ) {
                                         continue;
                                    }
                                    if($value[0]!='')
                                        $variation_label.=' - '.str_replace(array("pa_","attribute_"),"",$name).' : '.$value[0];
                                }

                            }


                            $title = '<h3 class="ls-result-title"><span class="brand"></span><a href="'.$product->get_permalink().'">'.$product->get_title().$variation_label .$terms.' </a></h3><h4></h4>';
                        }
?>

Solutions Collecting From Web of "I want to get product attirbute in the section below"