Migrating to Shopify API 2024-07 - Product Creation with Default Variants

Hi,

We are in the process of migrating our APIs to Shopify’s 2024-07 version, which introduces significant changes compared to the 2023-07 version. I’ve encountered an issue with the productCreate mutation and need your assistance.

Key Changes and Challenges:

  1. In the 2024-07 version, variant data must be sent in a separate mutation (productVariantsBulkCreate) instead of within the productInput as in the previous version.
  2. For products with multiple variants, I’ve successfully implemented this using productCreate and productVariantsBulkCreate mutations.
  3. However, for products with default variants and options, I’m facing difficulties:
  • The productVariantsBulkCreate mutation creates new variants, but I need to create default variant.
  • Using productCreate alone doesn’t allow me to include crucial details like SKU, price, weight, and inventoryItem, as these belong to variantsInput.

Assistance Required:-
I need guidance on how to create a product with default variants using GraphQL in the new API version. Specifically, I’m looking for a way to include variant-specific details (SKU, price, weight, inventoryItem) when creating a product with default variants.
Your expertise in resolving this issue would be greatly appreciated. Please let me know if you need any further information or clarification.

Thank you for your support.

I suggest you to take a look at the productSet mutation:
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productSet
maybe it can be useful for your use case.

Otherwise yess, now you need to first create the product and than create / update the variants.
When you create a product without variants, a default variants is created with option “Title” and value “Default title”.
You can either update that variant or create a new one using the strategy “REMOVE_STANDALONE_VARIANT” to overwrite it.

Hope it can help!

2 Likes