title: Woocommerce get variations list of product
body: <p>I have a plugin that save a product in Woocomerce as a sample product, so I have a hook launched just after save of this plugin to change the product to variable and init some default attributes and variations I have made it like this:</p>
  <pre><code>//change type
  $product_classname = WC_Product_Factory::get_product_classname($product_id, 'variable');
  $new_product = new $product_classname($product_id);
   
  // link default attribute
  $attributes = create_default_attributes();
  $new_product-&gt;set_attributes($attributes);
  
  // link all variation
  $data_store = $product-&gt;get_data_store();
  $data_store-&gt;create_all_product_variations($product);
  
  $new_product-&gt;save();
  
  function create_default_attributes()
  {
      $attribute_taxonomies = wc_get_attribute_taxonomies();
      $attributes = array();
      if (!empty($attribute_taxonomies)) {
          $tax_custom = false;
          foreach ($attribute_taxonomies as $tax) {
              $is_custom_name = &quot;is_custom _&quot; . $tax-&gt;attribute_id;
              $is_custom = get_option($is_custom _name);
              if ($is_custom == 1) {
                  $tax_custom = $tax;
                  break;
              }
          }
          if ($tax_custom) {
              $attribute_taxonomy_name = wc_attribute_taxonomy_name($tax_custom-&gt;attribute_name);
              $attribute = new WC_Product_Attribute();
              $attribute-&gt;set_id($tax_custom-&gt;attribute_id);
              $attribute-&gt;set_name($attribute_taxonomy_name);
              $all_terms = get_terms($attribute_taxonomy_name);
              $option = array();
              if (!empty($all_terms)) {
                  foreach ($all_terms as $term) {
                      $option[$term-&gt;term_id] = $term-&gt;name;
                  }
              }
              $attribute-&gt;set_options($option);
              $attribute-&gt;set_position(0);
              $attribute-&gt;set_visible(1);
              $attribute-&gt;set_variation(1);
              $attributes[] = $attribute;
          }
      }
      return $attributes;
  }
  </code></pre>
  <p>all this thing work as expected now i need to change all variations price to the default price of sample product like this:</p>
  <pre><code>$variations=$new_product-&gt;get_children();
  write_log($variations);
  foreach ($variations as $value) {
      $single_variation = new WC_Product_Variation($value);
  }
  </code></pre>
  <p>The list of $variations is empty ? why is empty ? when the hook is finished i verify in the admin area the list of all variation is still here, any idea ?</p>