getSingleAttributeByMarkerSet
Getting one attribute with data from the attribute set.
Description
This method return a single attribute with data from the attribute sets. It returns a Promise that resolves to an IAttributesSetsEntity object.
AttributesSets.getSingleAttributeByMarkerSet(
setMarker*,
attributeMarker*,
langCode
);
Parameters schema
Schema
setMarker(required): string
Text identifier (marker) of the attribute set
example: "productAttributes"
attributeMarker(required): string
Text identifier (marker) of the attribute in the set
example: "color"
langCode: string
Language code. Default: "en_US"
example: "en_US"
Examples
Minimal example
const response = await AttributesSets.getSingleAttributeByMarkerSet('list1', 'list1');
Example with langCode attribute
const response = await AttributesSets.getSingleAttributeByMarkerSet('list1', 'list1', 'en_US');
Example response
{
"type": "string",
"value": {},
"marker": "admin-text",
"position": 1,
"listTitles": [],
"validators": {},
"initialValue": null,
"localizeInfos": {
"title": "Admins text"
},
"additionalFields": {}
}
Response schema
Schema: IAttributesSetsEntity
type: AttributeType
Attribute type.
example: "string", "text", "integer", "etc"
value: unknown
Value of the attribute, which can be of any type.
initialValue: unknown
Initial value of the attribute.
marker: string
Textual identifier of the attribute (marker).
example: "color", "size", "etc"
position: number
Position number for sorting.
example: 1
listTitles: IListTitle[]
Array of values (with extended data) for list and radioButton attributes; empty array for non-list types.
example:
[
{
"title": "red",
"value": 1,
"position": 1,
"extendedValue": null,
"extendedValueType": null
},
{
"title": "yellow",
"value": 2,
"position": 2,
"extendedValue": null,
"extendedValueType": null
}
]
listTitles.title: string
The title or name associated with the list item.
example: "Item Name"
listTitles.value: number | string
The value of the list item, which can be either a number or a string depending on the context.
example: 42
listTitles.position: string | number | null
The position of the list item, which can be represented as a string, number, or null if not applicable.
example: 1
listTitles.extended: object
An object containing additional properties or metadata related to the list item. This could include any extra details that extend the basic information.
listTitles.extended.value: string | null
The extended value, which can be a string or null.
example: "extra_value"
listTitles.extended.type: string | null
The type of the extended value, which can be a string or null.
example: "color"
validators: IAttributeValidators
Set of validators for validation; empty object when no validators are configured.
example:
{
"requiredValidator": {
"strict": true
},
"defaultValueValidator": {
"fieldDefaultValue": 11
}
}
validators.requiredValidator: object
Marks the field as required. Shape: { strict: boolean }.
example: { strict: true }
validators.stringInspectionValidator: object
Length constraints for string fields. Shape: { stringMin: number; stringMax: number; stringLength: number }.
validators.emailInspectionValidator: boolean
Toggle for email-format validation.
validators.defaultValueValidator: object
Default value configuration with optional custom error text. Shape: { customErrorText?: string; fieldDefaultValue?: unknown; fieldDefaultValue2?: unknown }.
localizeInfos: IAttributeLocalizeInfo
The name of the template, taking into account localization.
example:
{
"title": "My attribute"
}
additionalFields: Record<string, IAttributesSetsEntity>
Nested sub-attributes keyed by marker; empty object when none.