I try to run this query:
$query = <<<QUERY
mutation productVariantsBulkCreate(\$productId: ID!, \$variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkCreate(productId: \$productId, variants: \$variants) {
productVariants {
id
inventoryItem {
id
}
}
userErrors {
field
message
}
}
}
QUERY;
$variables = [
"productId" => $productParentId,
"strategy" => "REMOVE_STANDALONE_VARIANT",
"variants" => [
"price" => $requestBodyData['price'],
"barcode" => $productVariant->ean,
"taxable" => true,
"inventoryPolicy" => "DENY",
"inventoryItem" => [
"sku" => $productVariant->ean,
"tracked" => true,
"cost" => $productVariant->unit_cost,
"measurement" => [
"weight" => [
"unit" => "GRAMS",
"value" => $productVariant->weight
]
]
],
"inventoryQuantities" => [
[
"availableQuantity" => $requestBodyData['stock'],
"locationId" => "gid://shopify/Location/" . ShopifyService::LOCATION
]
],
"optionValues" => [
[
"name" => "Red",
"optionName" => "Color",
],
[
"name" => "Large",
"optionName" => "Size",
]
]
]
];
It returns this error: “message”:“Option does not exist”
Contacted support but they didn’t know the problem.