Hi!
it´s an exact copy from this blogpost:
$prod_data = [
'name' => 'A great product',
'type' => 'variable',
'description' => 'A very meaningful product description',
'images' => [
[
'src' => 'https://pathTo.jpg',
'position' => 0,
],
],
'categories' => [
[
'id' => 1,
],
],
'attributes' => [
[
'id' => 5,
'variation' => true,
'visible' => true,
'options' => [ 'S', 'M', 'L' ],
],
],
];
$this->product = $this->api->post( 'products', $prod_data );
$variation_data = [
'regular_price' => '35.00',
'image' => [
'src' => 'https://pathTo.jpg',
],
'attributes' => [
[
'id' => 5,
'position' => 0,
'option' => 'S',
],
],
];
$id = $this->product->id;
$this->api->post( "products/$id", $variation_data );