Skip to main content

generateSKU

Requires at least one of the permissions products:product:create or products:product:update.

Generates the next SKU from the active SKU pattern that matches the brand and category, or a plain sequential SKU with an optional prefix when none matches. The result says whether the SKU is free, and failures come back in the result instead of as an error. Needs the products create or update permission.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation GenerateSKU($generateSKUInput: GenerateSKUInput!) {
generateSKU(generateSKUInput: $generateSKUInput) {
error
isValid
sku
}
}

Variables:

{
"generateSKUInput": {}
}

Response:

{
"data": {
"generateSKU": {
"error": "string",
"isValid": true,
"sku": "string"
}
}
}
generateSKU(
generateSKUInput: GenerateSKUInput!
): GeneratedSKU!

Arguments​

generateSKU.generateSKUInput ● GenerateSKUInput! non-null input​

The optional brand, category, prefix and custom pattern variables.

Type​

GeneratedSKU object​

A generated SKU.