title: Woocommerce: function to update all products
body: <p>I have an issue with my Woocommerce products. This issue is fixed if I just update the product (edit the product and click in the Update button) with no changes at all.</p>
  
  <p>I have around 2000 products in my site, then I am thinking of doing this using a function in my function.php file.</p>
  
  <p>It should be something like this, I just need the line which update the product.</p>
  
  <pre><code>function update_all_products(){
  
      // getting all products
      $products = get_posts( $args );
  
      // Going through all products
      foreach ( $products as $key =&gt; $value ) {
  
          // the product ID
          $product_id = $value-&gt;ID;
  
          // update product
          update_post_meta...(NEED HELP HERE)...
  
     } //..end foreach
  }
  
  // fire the function
  update_all_products();
  </code></pre>