I have a problem with new product model. I want to create a example product with graphql
my referance: https://shopify.dev/docs/api/admin-graphql/unstable/mutations/productCreate?example=Create+a+product+with+product+options+and+option+values&language=cURL#argument-input
As you can see in this screenshot, this product have Color and Size options and there are 2 values for each option.
When I use this example,
It generates only first values. I tried lots of methods but I could not solve it.
My php code;
$accessToken = $shopify->get_token();
$shopUrl = 'https://' . $shopify->get_shop() . '/admin/api/unstable/graphql.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $shopUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-Shopify-Access-Token: '.$accessToken,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{n"query": "mutation CreateProductWithOptions($input: ProductInput!) { productCreate(input: $input) { userErrors { field message } product { id options { id name position values optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }",n "variables": {n "input": {n "title": "New product",n "productOptions": [n {n "name": "Color",n "values": [n {n "name": "Red"n },n {n "name": "Green"n }n ]n },n {n "name": "Size",n "values": [n {n "name": "Small"n },n {n "name": "Medium"n }n ]n }n ]n }n }n}");
$response = curl_exec($ch);
curl_close($ch);