To get number of woocommerce published products –
$total_products = count( get_posts( array('post_type' => 'product', 'post_status' => 'publish', 'fields' => 'ids', 'posts_per_page' => '-1') ) );
To get attributes count –
$total_attribute_terms = get_terms('pa_'. $attribute_slug, array('hide_empty' => false, 'fields' => 'count') );
The $attribute_slug
can be found on Attribute edit page – Wp admin -> Products -> Attributes -> click on fly-out menu edit
(not name)