hi yes i did, i posted it in wordpress overflow, i really forgot to post it here also!
Found the solution to make a product attribute, a variation. Lets say we have wp_set_object_terms( $post_id, ‘XL’, ‘pa_size’ ); The above is a custom attribute (a size attribute). Making it a variation will look like
$new_post = array(
‘post_title’ => “Custom Variable”,
‘post_content’ => ‘Lorem ipsum dolor sit amet…’,
‘post_status’ => ‘publish’,
‘post_type’ => ‘product’
);
$skuu = “random”;
$post_id = wp_insert_post($new_post);
update_post_meta($post_id, ‘_sku’, $skuu );
update_post_meta( $post_id, ‘_price’, “25” );
//made it variable but variations wont be added!
wp_set_object_terms ($post_id, ‘variable’, ‘product_type’);
wp_set_object_terms( $post_id, ‘XL’, ‘pa_size’ );
/* the solution is here under */
$thedata = Array(‘pa_size’=>Array(
‘name’=>’pa_size’,
‘value’=>”,
‘is_visible’ => ‘1’,
‘is_variation’ => ‘1’,
‘is_taxonomy’ => ‘1’
));
update_post_meta( $post_id,’_product_attributes’,$thedata);
/* end of my solution */
update_post_meta( $post_id, ‘_visibility’, ‘search’ );
update_post_meta( $post_id, ‘_stock_status’, ‘instock’);
so now you have it pa_size its a variation