There are a lot of answers of your question. Here are some examples from them:
From here:
$brand_terms = get_the_terms( $post, 'pa_liquor-brands' );
And here:
$product->get_attribute( 'your_attr' );
Instead of getting page $args, define global $product
and extract from it any attributes you need.
Getting products
using attributes
( your question answer, got from here ):
// The query
$products = new WP_Query( array(
'post_type' => array('product'),
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array( array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN',
) ),
'tax_query' => array( array(
'taxonomy' => 'pa_color',
'field' => 'slug',
'terms' => array('blue', 'red', 'green'),
'operator' => 'IN',
) )
) );
// The Loop
if ( $products->have_posts() ): while ( $products->have_posts() ):
$products->the_post();
$product_ids[] = $products->post->ID;
endwhile;
wp_reset_postdata();
endif;
// TEST: Output the Products IDs
print_r($product_ids);