Closed devdightinfotech closed 1 year ago
I got the solution here it is:
$productData = [
'title' => 'Product Test 1',
'body_html' => 'This is product descriptions',
'vendor' => 'Test Brand',
'product_type' => 'Jeans',
'tags' => 'blue',
'variants' => array(
array(
'option1' => 'Small',
'option2' => 'Red',
'price' => 19.99,
'sku' => 'SKU123'
),
array(
'option1' => 'Small',
'option2' => 'Blue',
'price' => 19.99,
'sku' => 'SKU124'
),
array(
'option1' => 'Large',
'option2' => 'Red',
'price' => 21.99,
'sku' => 'SKU125'
),
array(
'option1' => 'Large',
'option2' => 'Blue',
'price' => 21.99,
'sku' => 'SKU126'
)
),
)
'options' => array(
array(
'name' => 'Size',
'values' => [
'Small',
'Large'
]
),
array(
'name' => 'Color',
'values' => [
'Red',
'Blue'
]
),
)
];
$addProduct = $shopify->Product->post($productData);
Using this ShopifySDK, I tried to create product options and variants, but it is not created. Here is my code:
Product is being created but not products options and variants
Help me to create products options and variants correctly in Shopify.