How to add product variations While Bulk Creating Items via bulkCreateOrReplaceInventoryItem

37 Views Asked by At

How to add product variations While Bulk Creating Items via bulkCreateOrReplaceInventoryItem?

I have this building of the products in Laravel with variations which is not working:

$requestBody = [
            'sku' => '35225555566777815',
            'locale' => 'en_US',
            'product' => [
                'title' => 'Example Product',
                'description' => 'A great product with variations',
            ],
            'variations' => [
                'variation' => [
                    'sku' => 'VAR123-RED-SM',
                    'price' => '19.99',
                    'quantity' => 10,
                ]
            ],
        ];

and this is what I get only when I retrieve the product again

{"sku":"35225555566777815","locale":"en_US","product":{"title":"Example Product","description":"A great product with variations"}}
$requestBody = [
            'sku' => '35225555566777815',
            'locale' => 'en_US',
            'product' => [
                'title' => 'Example Product',
                'description' => 'A great product with variations',
            ],
            'variations' => [
                'variation' => [
                    'sku' => 'VAR123-RED-SM',
                    'price' => '19.99',
                    'quantity' => 10,
                ]
            ],
        ];

I tried to send the product with this shape.

the access token is working, I tested it many times.

0

There are 0 best solutions below