wordpresse-commercewoocommerceproductskus

Woocommerce: get a list for all sku product


I would to get in a <li> list all sku there are in an ecommerce. I belive that I should use foreach cycle, but I don't know how to recall the selection of all products.

Thanks for all reply, and sorry for my bad english. Greatings


Solution

  • Please try this. Let me know if this works perfectly ;)

    $args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
    query_posts( $args );
    if( have_posts() ):
        echo '<ul>';
        while ( have_posts() ) : the_post();
            echo '<li>'. $product->get_sku() . '</li>';
        endwhile;
        echo '</ul>';
    endif;
    

    Cheers!