Woocommerce以编程方式将“简单”产品更改为具有下载和硬拷贝变体的“可变”产品

I have a woocommerce (wordpress) up to date, with over 10k products which I need to create variations for, there are four kinds of variations, two are hardcopy with inventory control, the other two variation of the products does not need inventory control.

I have check out so many various ways people have created programmatically variations and attempted their scripts on a dev site, that I am starting to get bug eyed.

<?php

require_once('wp-load.php'); // load the wordpress core
require_once('functions.php') ; // custom functions to grab related data from the wpdb

$import_id = GetTheNextProduct(); // non-wordpress database
$is_variable_product = CheckIfVariable($import_id) ;
 $post_id = GetRelatedWPDI($import_id); // returns related word press post `ID` of the product 
 // ... other variables are set in the same way... ie: $sku = GetSKU($import_id) ;
 // the problem I am having is getting the current variation array into woocommerce variations, 
 // I've been able to do everything else.
 if($is_variable_product == 1) {
 $variations = GetVariations($import_id) ;
 // woocommerce proper way to create variations....????
 } 
 /* out example of $variations...

 $variations = array(
 "0" => array(
         "ProductType" => "Small PDF",
         "filepath" => "/path/to/pdf/file.pdf",
         "filename" => "file.pdf",
         "price" => "5.00",
         "_visibility" => "visible",
         "_stock_status" => "instock",
         "_downloadable" => "yes",
         "_weight" => "",
         "_length" => "",
         "_width" => "",
         "_height" => "",
         "_width" => "", 
         "inventory" => "unlimited",
         "_sku" => "parent",
         ),
 "1" => array(
         "ProductType" => "Large PDF",
         "filepath" => "/path/to/pdf/file-large.pdf",
         "filename" => "file-large.pdf",
         "price" => "10.00",
         "_visibility" => "visible",
         "_stock_status" => "instock",
         "_downloadable" => "yes",
         "_weight" => "",
         "_length" => "",
         "_width" => "",
         "_height" => "", 
         "_width" => "",
         "inventory" => "unlimited",
         "_sku" => "parent",
         ),
 "2" => array(
         "ProductType" => "Small Hardcopy",
         "filepath" => "",
         "filename" => "",
         "price" => "15.00",
         "_visibility" => "visible",
         "_stock_status" => "instock",
         "_downloadable" => "yes",
         "_weight" => "0.5",
         "_length" => "",
         "_width" => "8",
         "_height" => "11",
         "_width" => "", 
         "inventory" => "123",
         "_sku" => "parent",
         ),
 "4" => array(
         "ProductType" => "Large Hardcopy",
         "filepath" => "",
         "filename" => "",
         "price" => "20.00",
         "_visibility" => "visible",
         "_stock_status" => "instock",
         "_downloadable" => "yes",
         "_weight" => "0.5",
         "_length" => "",
         "_width" => "8",
         "_height" => "11",
         "_width" => "", 
         "inventory" => "456",
         "_sku" => "parent",
         ),
 )


 */

update_post_meta( $post_id, '_sku', $sku); 
update_post_meta( $post_id,'_visibility','visible');
wp_set_object_terms($post_id, 'variable', 'product_type');

// do something here to the current $variations array variable to...

$variation_id = wp_insert_post( $variation_post );
$variation = new WC_Product_Variation( $variation_id );

foreach($variations as $vars_sub){
    foreach($vars_sub as $key => $value) {
        update_post_meta( $variation_id, 'attribute_'.$key, $value );
        }
}

I've read, tried, so many of the script suggestions within stack, some which have helped a lot with simple products that remain simple... but this one has me stumped.