Hello,
I am building an application that synchronizes products between our application and Shopify. My goal is to create multiple products, each with a Title, Price, and SKU with one request. From what I understand, the SKU and Price can only be assigned to product variants. If I do not create any variants, Shopify uses a “default variant”, correct?
While importing new products into Shopify, I am trying to be as request-efficient as possible by using the mutations/productSet. However, I am encountering an issue where I am unable to assign the Price and SKU to the “default variant”. Is there a workaround for this, or am I approaching it incorrectly? Additionally, I would like to handle this in one mutation to keep our application logic simple and easily extendable in the future.
// here optionValues field is required for variants
PRODUCT_CREATE_INPUT = '{"input":{"title":"%s","variants":[{"sku":"%s","price":"%s"}]}, "synchronous": false}';`
CREATE_MUTATION = 'mutation {
bulkOperationRunMutation(
mutation: "mutation call($input: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $input) { product {title productType vendor} productSetOperation {id userErrors{code field message}} userErrors { message field } } }",
stagedUploadPath: "%s"
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}';
Thank you for your answers!
Bc. Martin Pech
EDIT: Found this solution, which works for me, but feels a little bit goofy. Better solutions are still appreciated.