title: Update WooCommerce products programmatically
body: <p>I'm currently migrating data from a custom CMS over to WooCommerce. I'm able to create the products fine using the following code:</p>
  
  <pre><code>try {
      $product = new WC_Product_Variable();
      $product-&gt;set_name($productData["Name"]);
      $product-&gt;set_description($productData["Description"]);
      $product-&gt;set_price($productData["Price"]);
      $product-&gt;set_sku("PW" . $productData["ID"]);
      $product-&gt;set_category_ids($productData["NewCategoryIds"]);
      $product-&gt;set_status($productData["OnlineStatus"]);
  
  ...
  </code></pre>
  
  <p>The problem I'm having though is that when I re-run my script, I get <code>WC_Data_Exception: Invalid or duplicated SKU</code>.</p>
  
  <p>This is odd, because when looking at the save function within the <code>WC_Product_Variable</code> class, the comment says:</p>
  
  <blockquote>
    <p>Save data (either create or update depending on if we are working on an existing product).</p>
  </blockquote>
  
  <p>... but the save function within that class doesn't appear to do any updating.</p>