Variant Group
Variant Group
Variant groups are collections of related variants. These groups allow you to manage and deliver content tailored to specific languages, regions, or other criteria, ensuring that users receive the most relevant version of the content based on their context or preferences.
Create variant group
The Create a variant group method creates a new variant group in a specific stack.
| Name | Type | Description |
|---|---|---|
| variant_group (required) | object | Details of the variant group object |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const variant_group = {
"name": "Colors",
"content_types": [
"iphone_product_page"
]
}
client
.stack({ api_key: 'api_key'})
.variantGroup()
.create({ variant_group })
.then((variantGroup) => console.log(variantGroup))Update variant group
The Update variant group method allows you to update the name of an existing variant group. You can also modify its JSON schema, including its fields and associated features.
| Name | Type | Description |
|---|---|---|
| variant_group_uid (required) | string | Enter the UID of the Variant Group |
| data (required) | Object | Details of the entry variant |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
const data = { name: 'updated name' }
client
.stack({ api_key: 'api_key'})
.variantGroup('variant_group_uid')
.update(data)
.then((variantGroup) => console.log(variantGroup))Delete variant group
The Delete variant group method allows you to permanently delete an existing variant group from your stack.
| Name | Type | Description |
|---|---|---|
| variant_group_uid (required) | string | Enter the UID of the Variant Group |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken });
client
.stack({ api_key: 'api_key'})
.variantGroup('variant_group_uid')
.delete()
.then((response) => console.log(response.notice))Get all variant group (For Stack and ContentType)
The Get all variant groups method allows you to retrieve details for all or specific variant groups.
| Name | Type | Description |
|---|---|---|
| params.query (required) | object | Queries to retrieve filtered results |
Example:
import * as contentstack from '@contentstack/management'
const client = contentstack.client({ authtoken })
client
.stack({ api_key: 'api_key'})
.variantGroup()
.query()
.find()
.then((response) => console.log(response))