How to get woocommerce product collection in template file

I found like this.
For More : https://docs.woocommerce.com/document/sample-products-loop/
https://www.philowen.co/blog/show-latest-woocommerce-products-in-your-template/

<?php
        $args = array(
            'post_type' => 'product',
            'posts_per_page' => 12
            );
        $loop = new WP_Query( $args );
        if ( $loop->have_posts() ) {
            while ( $loop->have_posts() ) : $loop->the_post();
                wc_get_template_part( 'content', 'product' );
            endwhile;
        } else {
            echo __( 'No products found' );
        }
        wp_reset_postdata();
    ?>

Just try it. i hope is useful