WP_Query multiple post results

Your loop is wrong, you should not use to foreach inside the while, simply add the classic the_post () using the variable of your loop in this case $ loop

for example

<?php 
    $args = array( 
        'post_type' => 'product', 
        'stock' => 1, 
        'posts_per_page' => 9,
        'product_cat' => $pagename, 
    );

    $loop = new WP_Query( $args );

    while($loop->have_posts()){
        $loop->the_post();
        ?>
        <div class="col-md-4">
            <?php the_post_thumbnail(); ?>
        </div>
        <?php
    }
?>