productVariantsBulkCreate api REMOVE_STANDALONE_VARIANT,After I add the parameters and upload the variants, the platform will delete the corresponding variants in 1-2 minutes.
- Call the productCreate interface to create a product
Participation:
mutation {
productCreate(product: {productOptions:[{values:[{name:"black"},{name:"Champagne"}],name:"Color"},{values:[{name:"230cm"},{name:"240cm"}],name:"Belt Length"}],vendor:"11",descriptionHtml:"<img src=\"https://ae01.alicdn.com/kf/S3e5a0a36fecc4f33abf01c20c3f8ae323.jpg\" /><br />\n<img src=\"https://ae01.alicdn.com/kf/S20a00303b1c444409b6549f5d40f653fR.jpg\" alt=\"\" /><br />\n<br />\n<p>\n\t波西米亚风pp草自由打结腰封百搭各种碎花沙滩裙\n</p>",title:"005-Bohemian pp grass freely knotted waist-sealed dress with broken flowers",seo:{description:"",title:""},productType:"12",tags:["12"],status:ACTIVE},media: [{alt:"main",mediaContentType:IMAGE,originalSource:"https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sbef014a658ce4a35bdb93e1d1e1bc86fc_88f3ec0d-a2b0-4602-b859-3b344505cb4e.jpg?v=1741779063"},{alt:"main",mediaContentType:IMAGE,originalSource:"https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S2d4521d77aac455cb6156e79610bdc8dc_ef11eb81-931d-4c4e-8e3c-7f50a1b2e72e.webp?v=1741779064"},{alt:"black240cm",mediaContentType:IMAGE,originalSource:"https://ae01.alicdn.com/kf/S3e5a0a36fecc4f33abf01c20c3f8ae323.jpg"},{alt:"black230cm",mediaContentType:IMAGE,originalSource:"https://ae01.alicdn.com/kf/S3e5a0a36fecc4f33abf01c20c3f8ae323.jpg"},{alt:"Champagne240cm",mediaContentType:IMAGE,originalSource:"https://ae01.alicdn.com/kf/Sfc0429906fca4f7899a6a8ad429cebf3h.jpg"},{alt:"Champagne230cm",mediaContentType:IMAGE,originalSource:"https://ae01.alicdn.com/kf/Sfc0429906fca4f7899a6a8ad429cebf3h.jpg"}]) {
product {
id
title
options {
id
name
position
optionValues {
id
name
hasVariants
}
}
}
userErrors {
field
message
}
}
}
return:
{
"data": {
"productCreate": {
"product": {
"id": "gid://shopify/Product/9041057120512",
"title": "005-Bohemian pp grass freely knotted waist-sealed dress with broken flowers",
"options": [
{
"id": "gid://shopify/ProductOption/11590289293568",
"name": "Color",
"position": 1,
"optionValues": [
{
"id": "gid://shopify/ProductOptionValue/3276427723008",
"name": "black",
"hasVariants": true
},
{
"id": "gid://shopify/ProductOptionValue/3276427755776",
"name": "Champagne",
"hasVariants": false
}
]
},
{
"id": "gid://shopify/ProductOption/11590289326336",
"name": "Belt Length",
"position": 2,
"optionValues": [
{
"id": "gid://shopify/ProductOptionValue/3276427788544",
"name": "230cm",
"hasVariants": true
},
{
"id": "gid://shopify/ProductOptionValue/3276427821312",
"name": "240cm",
"hasVariants": false
}
]
}
]
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 12,
"actualQueryCost": 12,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1988,
"restoreRate": 100.0
}
}
}
}
###2. Call the query product interface
Participation:
query {
product(id: "gid://shopify/Product/9041057120512") {
id
title
bodyHtml
vendor
productType
createdAt
handle
updatedAt
publishedAt
templateSuffix
tags
status
description
tracksInventory
media(first:250){
nodes{
id
mediaContentType
alt
}
}
images(first:250){
nodes{
id
url
altText
width
height
src
}
}
featuredImage{
id
url
altText
width
height
src
}
options{
id
name
position
values
}
variants(first:250){
nodes{
id
title
price
position
inventoryPolicy
compareAtPrice
updatedAt
createdAt
taxable
barcode
inventoryPolicy
sku
inventoryQuantity
inventoryItem{
id
tracked
measurement{
id
weight{
unit
value
}
}
requiresShipping
}
image{
id
url
}
unitPriceMeasurement{
measuredType
quantityUnit
quantityValue
referenceUnit
referenceValue
}
}
}
}
}
return
{
"data": {
"product": {
"id": "gid://shopify/Product/9041057120512",
"title": "005-Bohemian pp grass freely knotted waist-sealed dress with broken flowers",
"bodyHtml": "<img src=\"https://ae01.alicdn.com/kf/S3e5a0a36fecc4f33abf01c20c3f8ae323.jpg\"><br>\n<img src=\"https://ae01.alicdn.com/kf/S20a00303b1c444409b6549f5d40f653fR.jpg\" alt=\"\"><br>\n<br>\n<p>\n\t波西米亚风pp草自由打结腰封百搭各种碎花沙滩裙\n</p>",
"vendor": "11",
"productType": "12",
"createdAt": "2025-03-12T11:37:37Z",
"handle": "005-bohemian-pp-grass-freely-knotted-waist-sealed-dress-with-broken-flowers-5",
"updatedAt": "2025-03-12T11:37:53Z",
"publishedAt": null,
"templateSuffix": null,
"tags": [
"12"
],
"status": "ACTIVE",
"description": "波西米亚风pp草自由打结腰封百搭各种碎花沙滩裙",
"tracksInventory": false,
"media": {
"nodes": [
{
"id": "gid://shopify/MediaImage/35478727590144",
"mediaContentType": "IMAGE",
"alt": "main"
},
{
"id": "gid://shopify/MediaImage/35478727622912",
"mediaContentType": "IMAGE",
"alt": "main"
},
{
"id": "gid://shopify/MediaImage/35478727655680",
"mediaContentType": "IMAGE",
"alt": "black240cm"
},
{
"id": "gid://shopify/MediaImage/35478727688448",
"mediaContentType": "IMAGE",
"alt": "black230cm"
},
{
"id": "gid://shopify/MediaImage/35478727721216",
"mediaContentType": "IMAGE",
"alt": "Champagne240cm"
},
{
"id": "gid://shopify/MediaImage/35478727753984",
"mediaContentType": "IMAGE",
"alt": "Champagne230cm"
}
]
},
"images": {
"nodes": [
{
"id": "gid://shopify/ProductImage/43182053916928",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sbef014a658ce4a35bdb93e1d1e1bc86fc_db800dbd-b821-4e01-a97d-1cfcdc33a99e.jpg?v=1741779459",
"altText": "main",
"width": 1340,
"height": 1785,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sbef014a658ce4a35bdb93e1d1e1bc86fc_db800dbd-b821-4e01-a97d-1cfcdc33a99e.jpg?v=1741779459"
},
{
"id": "gid://shopify/ProductImage/43182053884160",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S2d4521d77aac455cb6156e79610bdc8dc_1fdbf7e1-c3da-44bf-a003-81792eeba6c9.webp?v=1741779459",
"altText": "main",
"width": 1340,
"height": 1785,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S2d4521d77aac455cb6156e79610bdc8dc_1fdbf7e1-c3da-44bf-a003-81792eeba6c9.webp?v=1741779459"
},
{
"id": "gid://shopify/ProductImage/43182054015232",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S3e5a0a36fecc4f33abf01c20c3f8ae323_2d7f44e9-f37f-4926-9dea-ab4249839532.webp?v=1741779459",
"altText": "black240cm",
"width": 1338,
"height": 1785,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S3e5a0a36fecc4f33abf01c20c3f8ae323_2d7f44e9-f37f-4926-9dea-ab4249839532.webp?v=1741779459"
},
{
"id": "gid://shopify/ProductImage/43182053982464",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S3e5a0a36fecc4f33abf01c20c3f8ae323_308e904d-bdd6-4e3e-9bb3-49a586313cf3.webp?v=1741779459",
"altText": "black230cm",
"width": 1338,
"height": 1785,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/S3e5a0a36fecc4f33abf01c20c3f8ae323_308e904d-bdd6-4e3e-9bb3-49a586313cf3.webp?v=1741779459"
},
{
"id": "gid://shopify/ProductImage/43182053949696",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sfc0429906fca4f7899a6a8ad429cebf3h_fd34b406-1295-460d-b87a-573894952429.webp?v=1741779459",
"altText": "Champagne240cm",
"width": 900,
"height": 1200,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sfc0429906fca4f7899a6a8ad429cebf3h_fd34b406-1295-460d-b87a-573894952429.webp?v=1741779459"
},
{
"id": "gid://shopify/ProductImage/43182053851392",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sfc0429906fca4f7899a6a8ad429cebf3h_afdcd161-8a95-4315-ad53-0b10fa45ce29.webp?v=1741779459",
"altText": "Champagne230cm",
"width": 900,
"height": 1200,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sfc0429906fca4f7899a6a8ad429cebf3h_afdcd161-8a95-4315-ad53-0b10fa45ce29.webp?v=1741779459"
}
]
},
"featuredImage": {
"id": "gid://shopify/ProductImage/43182053916928",
"url": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sbef014a658ce4a35bdb93e1d1e1bc86fc_db800dbd-b821-4e01-a97d-1cfcdc33a99e.jpg?v=1741779459",
"altText": "main",
"width": 1340,
"height": 1785,
"src": "https://cdn.shopify.com/s/files/1/0632/3925/8368/files/Sbef014a658ce4a35bdb93e1d1e1bc86fc_db800dbd-b821-4e01-a97d-1cfcdc33a99e.jpg?v=1741779459"
},
"options": [
{
"id": "gid://shopify/ProductOption/11590289293568",
"name": "Color",
"position": 1,
"values": [
"black"
]
},
{
"id": "gid://shopify/ProductOption/11590289326336",
"name": "Belt Length",
"position": 2,
"values": [
"230cm"
]
}
],
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/46483547750656",
"title": "black / 230cm",
"price": "0.00",
"position": 1,
"inventoryPolicy": "DENY",
"compareAtPrice": null,
"updatedAt": "2025-03-12T11:37:37Z",
"createdAt": "2025-03-12T11:37:37Z",
"taxable": true,
"barcode": null,
"sku": "",
"inventoryQuantity": 0,
"inventoryItem": {
"id": "gid://shopify/InventoryItem/48598491889920",
"tracked": false,
"measurement": {
"id": "gid://shopify/InventoryItemMeasurement/47556785307904",
"weight": {
"unit": "KILOGRAMS",
"value": 0.0
}
},
"requiresShipping": true
},
"image": null,
"unitPriceMeasurement": {
"measuredType": null,
"quantityUnit": null,
"quantityValue": 0.0,
"referenceUnit": null,
"referenceValue": 0
}
}
]
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 75,
"actualQueryCost": 19,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1981,
"restoreRate": 100.0
}
}
}
}
At this point, the platform has generated a default variant,[image-20250312194111716](C:\Users\35735\AppData\Roaming\Typora\typora-user-images\image-20250312194111716.png)
###3. Call the create variant interface productVariantsBulkCreate
```graphql
mutation ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkCreate(productId: $productId, variants: $variants) {
productVariants {
id
title
selectedOptions {
name
value
}
}
userErrors {
field
message
}
}
}
Variable input
```json
{
"productId": "gid://shopify/Product/9041057120512",
"variants": [
{
"inventoryItem": {
"requiresShipping": true,
"sku": "0312005-1",
"measurement": {
"weight": {
"unit": "KILOGRAMS",
"value": 0.1
}
}
},
"taxable": true,
"price": "59.9",
"inventoryPolicy": "CONTINUE",
"mediaId": "gid://shopify/MediaImage/35478727655680",
"barcode": "",
"inventoryQuantities": {
"availableQuantity": 83,
"locationId": "gid://shopify/Location/67950739712"
},
"optionValues": [
{
"name": "black",
"optionName": "Color"
},
{
"name": "240cm",
"optionName": "Belt Length"
}
],
"compareAtPrice": "69.9"
},
{
"inventoryItem": {
"requiresShipping": true,
"sku": "0312005-3",
"measurement": {
"weight": {
"unit": "KILOGRAMS",
"value": 0.1
}
}
},
"taxable": true,
"price": "59.9",
"inventoryPolicy": "CONTINUE",
"mediaId": "gid://shopify/MediaImage/35478727721216",
"barcode": "",
"inventoryQuantities": {
"availableQuantity": 1,
"locationId": "gid://shopify/Location/67950739712"
},
"optionValues": [
{
"name": "Champagne",
"optionName": "Color"
},
{
"name": "240cm",
"optionName": "Belt Length"
}
],
"compareAtPrice": "69.9"
},
{
"inventoryItem": {
"requiresShipping": true,
"sku": "0312005-4",
"measurement": {
"weight": {
"unit": "KILOGRAMS",
"value": 0.1
}
}
},
"taxable": true,
"price": "59.9",
"inventoryPolicy": "CONTINUE",
"mediaId": "gid://shopify/MediaImage/35478727753984",
"barcode": "",
"inventoryQuantities": {
"availableQuantity": 3,
"locationId": "gid://shopify/Location/67950739712"
},
"optionValues": [
{
"name": "Champagne",
"optionName": "Color"
},
{
"name": "230cm",
"optionName": "Belt Length"
}
],
"compareAtPrice": "69.9"
}
]
}
return
{
"data": {
"productVariantsBulkCreate": {
"productVariants": [
{
"id": "gid://shopify/ProductVariant/46483561087232",
"title": "black / 240cm",
"selectedOptions": [
{
"name": "Color",
"value": "black"
},
{
"name": "Belt Length",
"value": "240cm"
}
]
},
{
"id": "gid://shopify/ProductVariant/46483561120000",
"title": "Champagne / 240cm",
"selectedOptions": [
{
"name": "Color",
"value": "Champagne"
},
{
"name": "Belt Length",
"value": "240cm"
}
]
},
{
"id": "gid://shopify/ProductVariant/46483561152768",
"title": "Champagne / 230cm",
"selectedOptions": [
{
"name": "Color",
"value": "Champagne"
},
{
"name": "Belt Length",
"value": "230cm"
}
]
}
],
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 11,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 2000.0,
"currentlyAvailable": 1989,
"restoreRate": 100.0
}
}
}
}
###4. Issues
Based on the first 3 steps, it was found that the created variant will be deleted in the background after 1-2 minutes
2. When calling productCreate, how to recreate the variant generated by the platform by default? If you upload it in the productVariantsBulkCreate interface, it will report that the variant already exists. Please change the name.
3. After I added the ‘DECOVE-STANDALONEVNet’ parameter to the productVariantsBulkCreate interface and uploaded the variant, the platform will also delete the corresponding variant in 1-2 minutes.