Hi there !
I am trying to find a solution to create a product with variant and I am running into multiple issues.
My plan is to use the productCreate mutation, then productVariantsBulkCreate with a strategy of REMOVE_STANDALONE_VARIANT. I am probably using it wrong but here is the issue I am having :
When I create the product without options/optionsvalues, it creates the default variant
I then want to productVariantsBulkCreate, but the mutation says that I have to first specify the options and values in the product
So I updated the creation of the product by giving the list of options/optionvalues. When I do this, only 1 variant is created in Shopify with the first combination of the first option values I give (why only one ?)
So if I try to productVariantsBulkCreate, it first tells me that the first variant already exists.
Not sure what to do!
I also know about the productSet, but with more than 100 variants, we have to run it async, and as I need to get all the IDs of each variants, productVariantsBulkCreate seems easier.
I do see a few way to do this, but nothing seems perfectly clean. The productCreate + productVariantsBulkCreate seems like a good option for my need but I cannot find a way to make it work.
So I am now trying to use the productSet. The variant structure is something new … the sku is not in InventoryItem, the inventory quantity has its own fields, we cannot set measurement. Is this even done by the same team in Shopify?
How can the experience to create to product can be that bad?
whats wrong with doing productCreate + productVariantsBulkCreate?
I believe the only thing you’re missing is when you do the productCreate you also need to add all of the options so that when you do the productVariantsBulkCreate the options are there to attach to.
I am also need to this so not 100% but that has worked for me when doing a small number of variants.
There is nothing really wrong with it. But when you create the product, we have two choices:
We give the list of optionValues and it will create a first variant with the first set of optionValues, we then have to create all the other variants using productVariantsBulkCreate. This is probably what I am going to do. What I don’t like about it is : why does it create the first variant only (probably because it needs at least one variant)? But why does the REMOVE_STANDALONE_VARIANT exists if we have to send the optionValues anyway (and it create a first variant). + we have to batch operation on our side because productVariantsBulkCreate accepts only 250 variants.
We use the productSet, but the graphql input is completely different. You have the option to set inventory quantities, but it doesn’t set tracked to true in the inventoryItem. So we have to do another mutation after anyway.
I feel like there are multiple pieces of the puzzle and everything doesn’t fit together for now. Eveything is way too complicated for no reason (don’t get me started on how optionValues are handled…). There are multiple ways of doing the same things, but none of them is fully complete.
This definitely feels like there are pieces missing.
We use productCreate to create our new product and first variant.
We then track what the first variant options were, and skip that variant when using productVariantsBulkCreate.
The problem with this approach is that the initial variant is missing properties - sku, and inventoryItem properties for example, that we have to go back and update outside of the bulk update (because we can’t “create” the initial variant completely unless it is created in the productCreate mutation???).
Removing the variant options from productCreate doesn’t allow any subsequent variants to be created, so it seems that we are stuck with dealing with the initial incomplete variant in some other fashion – my next step is to try productVariantsBulkUpdate to create the missing properties on the initial variant, then use productVariantsBulkUpdate to create the remaining variants…
One thing that might help is that the productVariantsBulkCreate mutation has a strategy argument which will remove the original product variant for you. This way you can include all the product’s variants, including the first one, in the payload of productVariantsBulkCreate.
shopify tells developer to migrate from rest to graphql and promotes an easy way to migrate using ProductSet. Which would be true, if the same fields are support, but we have to same problem: measurements is missing in productset, which makes everything very very complicated and rate limits and many conflicts makes it almost impossible. The failed and won’t help by just creating those measurements fields in ProductSet call. I am asking this since months. Maybe you have an idea? or how did you fix it?
This is exactly what we had to do. We also have to run inventoryActivate(), as the first variant isn’t automatically associated with our fulfillment.
Create Product using productCreate()
Identify and update initial variant using productVariantsBulkUpdate()
Activate inventory of first variant using inventoryActivate()
Create the additional variants using productVariantsBulkCreate()
Three calls that could have been done in one, potentially.
@Doud how did you manage to make the update calls - when a product changes or one of its variants? (or did you track all variation ids in your system?)