Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: How can I create a new variant with a custom SKU using the 2024-07 API?

Solved

How can I create a new variant with a custom SKU using the 2024-07 API?

jam_chan
Shopify Partner
938 24 193

In 2024 07 API, there will be a product variant field cleanup.

 

sku: This field will continue to be returned on the Product Variant model, but is not directly editable. Rather the field will just proxy the sku field from the inventory item.

If the SKU is not directly editable, how can I call the productVariantCreate mutation with a custom SKU in the ProductVariantInput?

 

I want to create a new variant with a custom SKU. Where is the field moved to?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Accepted Solution (1)

AsafGitai
Shopify Staff
109 16 45

This is an accepted solution.

Hi @jam_chan ,

 

productVariantCreate has an inventoryItem field that you can set these values in
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productvariantcreate

Also mentioned in 2024-04:

AsafGitai_0-1718583855074.png

 

View solution in original post

Replies 6 (6)

AsafGitai
Shopify Staff
109 16 45

This is an accepted solution.

Hi @jam_chan ,

 

productVariantCreate has an inventoryItem field that you can set these values in
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productvariantcreate

Also mentioned in 2024-04:

AsafGitai_0-1718583855074.png

 

JuusoPalander
Shopify Partner
6 0 1

Does that mean that in the API version 2024-04 there is not way to set variant SKU?

RobZone
Shopify Staff
77 11 23

The inventoryItem field is in 2024-04 as well, you do not need to wait for 2024-07.

To learn more visit the Shopify Help Center or the Community Blog.

jam_chan
Shopify Partner
938 24 193

@RobZone 

The inventoryItem field is in 2024-04 but the SKU field is not

https://shopify.dev/docs/api/admin-graphql/2024-04/input-objects/InventoryItemInput

https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productvariantcreate

 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
RobZone
Shopify Staff
77 11 23

My mistake, I was looking at the wrong graphql object.  You will need to use the deprecated sku field on ProductVariantInput for older versions.

To learn more visit the Shopify Help Center or the Community Blog.

JuusoPalander
Shopify Partner
6 0 1

Yeah as @jam_chan mentioned, it seems that the sku field has been forgotten from inventoryItem field in version 2024-04.