Hello,
We have to create over 100K products. We dont make use of any kind of product options (yet). So for each product, we need basic information set like:
Handle
title
Description Html
sku
price
Image1
Image2
It is our understanding that we need to create a product, and one variant for each product. Here is the workflow we are trying to use:
- Call: productCreate mutation. store the returned product Id for later.
- Call ProductVariantsCreate mutation (known as productVariantsBulkCreate). Pass in the product ID.
I have a few questions.
- Looking at your documentation for ProductVariantsCreate, it shows this json for the inputs:
{
"productId": "gid://shopify/Product/20995642",
"variants": [
{
"price": 15.99,
"compareAtPrice": 19.99,
"optionValues": [
{
"name": "Golden",
"optionId": "gid://shopify/ProductOption/328272167"
}
]
}
]
}
My first question is about:
variants[0].optionValues[0].optionId
- How are we passing in an ID here? Where did that ID come from? Is this required? This example in your documentation uses a “Golden” option, with an option ID specified. Im getting this back from your API:
“userErrors”:[{“field”:[“variants”,“0”],“message”:“You need to add option values for Title”}
So I assume this must be required.
- My second question is: Is a default variant created anyway when I create a new product? If so, then the process I am trying now would result in 2 variants (one real one and one bogus one).
Also, if you have any tutorial or best practices guide on how to do this, please give me the url.