New Product Model

I’m working on a POS app, which creates variants for products, many times the original product only has the default variant.

Problem: no matter what I pass to the “strategy” argument, looks like it’s always replacing the default variant, I tried many things like using productSet or even creating the productOptions before creating the variants, and the default variant always get replaced by the new one.

CURL with the mutation to create the new variant:

curl --location --request POST ‘https://SHOP.myshopify.com/admin/api/2024-07/graphql.json
–header ‘X-Shopify-Access-Token: TOKEN’
–header ‘Content-Type: application/json’
–data-raw ‘{“query”:“mutation ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n productVariantsBulkCreate(productId: $productId, variants: $variants, strategy: DEFAULT) {\n productVariants {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n userErrors {\n field\n message\n }\n }\n}”,“variables”:{“productId”:“PRODUCT_ID”,“variants”:[{“price”:10,“compareAtPrice”:0.01,“optionValues”:[{“name”:“Temporary testing 1”,“optionName”:“Title”}]}]}}’

Hey @JV_Ferreira :waving_hand: - this is expected behaviour across Shopify when it comes to the “Default” variant.

Essentially, when a product is created without variants initially, Shopify assigns a “default” variant automatically, so that inventory items, etc can be correctly mapped due to product inventory being associated with variants, rather than parent products.

For some merchants, this set up works if they’re just creating a single product via the admin, for example, but it is definitely confusing if you’re only working with the API, but once it’s replaced with a “real” variant, the default is removed.

Could you let me know what your use case is, just out of curiosity? Is your app creating variants for a specific reason? Just wondering if you’d be able to share the use case so I can raise it internally and potentially look into some workarounds for you. Hope to hear from you soon!