Importing Product Variants
Create and update ProductVariants in your Project.
The Product Variant data to import is represented by ProductVariantImport and included in a ProductVariantImportRequest, which is imported using Import ProductVariants.
This endpoint does not support importing Embedded Price data for Product Variants. To import Embedded Price data to a Product Variant, use the Importing Embedded Prices endpoint.
If you are only importing Attribute data, use the Importing Product Variant Patches endpoint.
For more information, see Choose the right Product import endpoint.
Read the Nested Attribute tutorial to learn how to create/update nested Attribute values with the commercetools Import API.
When importing Product Variant data to update an existing Product Variant, you must include existing values for fields or they will be removed when the Product Variant is imported.
Representations
ProductVariantImportRequest
The request body to import ProductVariants. Contains data for ProductVariants to be created or updated in a Project.
type | "product-variant"The Product Variant import resource type. |
resourcesArray of ProductVariantImport | The product variant import resources of this request. MaxItems:20 |
{"type": "product-variant","resources": [{"key": "red-t-shirt","sku": "red-t-shirt","product": {"key": "t-shirt","typeId": "product"},"isMasterVariant": true,"attributes": [{"name": "new","type": "boolean","value": true},{"name": "weight","type": "number","value": 12.5}],"assets": [{"id": "uuid-kafar7545792sd6r","key": "uuid-kafar7545792sd6r","sources": [{"uri": "http://www.example.com"}],"name": {"en": "asset name"}}],"images": [{"url": "https://www.commercetools.com/cli/data/253234387_1.jpg","dimensions": {"w": 1400,"h": 1400},"label": "tank top image Font"}]}]}
ProductVariantImport
The data representation for a ProductVariant to be imported that is persisted as a ProductVariant in the Project.
keyString | User-defined unique identifier. If a ProductVariant with this |
skuString | Maps to |
isMasterVariantBoolean |
|
attributesArray of Attribute | Maps to |
imagesArray of Image | Maps to |
assetsArray of Asset | Maps to |
stagedBoolean |
true |
product | The Product to which this Product Variant belongs. Maps to |
Attribute
Represents the value of attributes of a ProductVariant.
name- String - Optional
Required if used for ProductVariant import. Must not be set when used for ProductVariantPatch import. Must matchnameof an AttributeDefinition of the ProductType.type- String - Optional
Must matchtypeof an AttributeDefinition of the ProductType. Must be one of"boolean","boolean-set","date","date-set","datetime","datetime-set","enum","enum-set","lenum","lenum-set","ltext","ltext-set","money","money-set","number","number-set","reference","reference-set","text","text-set","time", or"time-set".
Do not include this field when importing nested Attributes.value- Required
Depends ontype. See List of Attributes. When importing nested Attributes,valueshould be an array of Attributes. For an example, see the Handling Structured and Nested Product Data tutorial.
Image
An Image uploaded to commercetools Composable Commerce is stored in a Content Delivery Network and it's available in several pre-defined sizes. If you already have an image stored on an external service, you can save the URL when creating a new product or adding a variant, or you can add it later.
urlString | URL of the image in its original size. The URL must be unique within a single variant. It can be used to obtain the image in different sizes. |
dimensions | Dimensions of the original image. This can be used by your application, for example, to determine whether the image is large enough to display a zoom view. |
labelString | Custom label that can be used, for example, as an image description. |
Asset
keyString | User-defined identifier for the asset. Asset keys are unique inside their container (a product variant or a category). |
sourcesArray of AssetSource | MinItems: 1 |
name | |
description | |
tagsArray of String | |
custom | The representation to be sent to the server when creating a resource with custom fields. |
AssetSource
An AssetSource is a representation of an Asset in a specific format, for example, a video in a certain encoding or an image in a certain resolution.
keyString | |
uriString | |
dimensions | The width and height of the Asset Source. |
contentTypeString |
AssetDimensions
The width and height of the Asset Source.
wInt | The width of the asset source. |
hInt | The height of the asset source. |
List of Attributes
The possible types for Attribute are listed below.
BooleanAttribute
This type represents an attribute whose value is either "true" or "false".
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "boolean" |
valueBoolean |
BooleanSetAttribute
This type represents an attribute whose value is set of boolean values.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "boolean-set" |
valueArray of Boolean |
DateAttribute
This type represents an attribute whose value is a date.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "date" |
valueDate |
DateSetAttribute
This type represents an attribute whose value is a set of dates.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "date-set" |
valueArray of Date-only |
DateTimeAttribute
This type represents an attribute whose value is a date with time.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "datetime" |
value |
DateTimeSetAttribute
This type represents an attribute whose value is a set of dates with time.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "datetime-set" |
valueArray of Datetime |
EnumAttribute
This type represents an attribute whose value is an enum. The attribute value refers to the key of the enum value.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "enum" |
valueString |
EnumSetAttribute
This type represents an attribute whose value is an enum. The attribute value refers to the key of the enum value.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "enum-set" |
valueArray of String |
LocalizableEnumAttribute
This type represents an attribute whose value is a localized enum. The attribute value refers to the key of the enum value.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "lenum" |
valueString |
LocalizableEnumSetAttribute
This type represents an attribute whose value is a localized enum. The attribute value refers to the key of the enum value.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "lenum-set" |
valueArray of String |
LocalizableTextAttribute
This type represents an attribute whose value is a localized text.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "ltext" |
value |
LocalizableTextSetAttribute
This type represents an attribute whose value is a localized text.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "ltext-set" |
valueArray of LocalizedString |
MoneyAttribute
This type represents an attribute whose value is a money object.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "money" |
value |
MoneySetAttribute
This type represents an attribute whose value is a set of money objects.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "money-set" |
valueArray of TypedMoney |
NumberAttribute
This type represents an attribute whose value is a number.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "number" |
valueFloat |
NumberSetAttribute
This type represents an attribute whose value is a set of numbers.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "number-set" |
valueArray of Number |
ReferenceAttribute
This type represents an attribute whose value is a key reference.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "reference" |
value | References a resource by key. |
{"type": "reference","name": "product-custom-object-ref-attribute","value": {"key": "custom-object-key","container": "custom-object-container","typeId": "key-value-document"}}
ReferenceSetAttribute
This type represents an attribute whose value is a set of references.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "reference-set" |
valueArray of KeyReference |
TextAttribute
This type represents an attribute whose value is a string.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "text" |
valueString |
TextSetAttribute
This type represents an attribute whose value is a set of strings.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "text-set" |
valueArray of String |
TimeAttribute
This type represents an attribute whose value is a time.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "time" |
valueTime |
TimeSetAttribute
This type represents an attribute whose value is a set of times.
nameString | The name of this attribute must match a name of the product types attribute definitions. The name is required if this type is used in a product variant and must not be set when used in a product variant patch. |
typeString | "time-set" |
valueArray of Time-only |
Import ProductVariants
Creates a request for creating new ProductVariants or updating existing ones.
manage_products:{projectKey}regionString | The Region in which the Project is hosted. |
projectKeyString | The Project key. |
importContainerKeyString | The ImportContainer used to create the new resource |
application/jsonapplication/json