after creating a product, and creating global attributes, I must add variations to the product, using API v3. this is the function:
function createVariationsById($id) {
$woocommerce = getWoocommerceConfig();
$data = [
'regular_price' => '15.00',
'manage_stock' => true,
'stock_quantity' => 10,
'attributes' => [
[
'id' => 8,
'name' => 'Taglia',
'option' => 'S'
],
],
];
echo json_encode($woocommerce->post('products/' . $id . '/variations', $data));
}
only the attributes are not added.
but the attribute with id 8 has already been created globally.
EDIT I did and posted the example here: https://github.com/mattepuffo/Woocommerce-api-import