Skip to main content

Attribute Set

This article provides comprehensive information and documentation on a set of API methods specifically designed to handle product attribute sets. By leveraging these methods, users can retrieve, create, and search product attribute sets, allowing for seamless integration and management of product data within the system.

The article includes detailed explanations, parameter descriptions, and usage examples for each API method, empowering developers to effectively utilize the capabilities provided by the product attribute set API.

Get Attribute Sets

Attribute sets are created by grouping attributes via attribute configs. Television, mobile phone, sneakers, t-shirt, and sofa can have different attribute(s) sets.

Note: Before creating a product, the "attribute set" that the product will have should be decided.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
limitintegerbodyAmount of line items per page that will be returned
pagestringbodyPage number to return

Request GET

Retrieves the entire attribute sets in the database. To filter the results check the Attribute Sets Search section.

Path:i1/attribute_set/

import requests

url = "https://{customer_api_url}/api/i1/attribute_set/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

params = {
'limit': '1',
'page': '3'
}

response = requests.get(url, headers=headers , params=params)
print(response.text)

Response

Response contains all attribute sets data with search parameters. Response status is expected to be HTTP-200 Successful.

Resource Properties are in Python format.

ParameterData TypeDescription
namestringSet's name
attribute_set_typedictType of the attribute set. It could be simple or group
valuestringAttribute set's value
labelstringAttribute set's label. It is used in the backend and frontend
attributeconfig_setarrayList of attributes included in the attribute set

“count” shows how many attribute sets exist in the system.

“next” shows the next cursor url to retrieve the desired attribute sets.

“previous” shows the previous cursor url to retrieve the desired attribute sets.

“results” shows every attribute sets detail.


{
"count": 56,
"next": "https://{customer_api_url}/api/i1/attribute_set/?limit=1&page=4",
"previous": "https://{customer_api_url}/api/i1/attribute_set/?limit=1&page=2",
"results": [
{
"id": 116,
"name": "Beden-Renk",
"attribute_set_type": {
"value": "simple",
"label": "Simple"
},
"attributeconfig_set": [
{
"pk": 2620,
"attribute": {
"pk": 1061,
"key": "oms_excluded",
"data_type": "dropdown",
"default_value": null,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": false,
"name": "Lorem Ipsum",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "oms_excluded",
"pre_attribute": false,
"description": "",
},
"attribute_set": 116,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 0,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
},
{
"pk": 2587,
"attribute": {
"pk": 206,
"key": "akinon_filterable_size",
"data_type": "dropdown",
"default_value": null,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"name": "Size",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "filterable_size",
"pre_attribute": false,
"description": null
},
"attribute_set": 116,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 1,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
},
{
"pk": 2191,
"attribute": {
"pk": 167,
"key": "top_category",
"data_type": "text",
"default_value": null,
"is_required": false,
"is_visible": false,
"is_searchable": false,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": false,
"name": "top_category",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "top_category",
"pre_attribute": false,
"description": null
},
"attribute_set": 116,
"is_required": false,
"is_visible": false,
"is_searchable": false,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": false,
"default_fields": [
"is_localizable"
],
"order": 4,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
},
{
"pk": 1898,
"attribute": {
"pk": 160,
"key": "Variant-Product1",
"data_type": "price",
"default_value": null,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": true,
"name": "Variant Product1",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "Variant Product",
"pre_attribute": false,
"description": null
},
"attribute_set": 116,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": true,
"default_fields": [
"is_localizable"
],
"order": 7,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
},
{
"pk": 1897,
"attribute": {
"pk": 269,
"key": "Forbidden",
"data_type": "bool",
"default_value": null,
"is_required": false,
"is_visible": false,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"name": "forbidden",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "forbidden",
"pre_attribute": false,
"description": null
},
"attribute_set": 116,
"is_required": false,
"is_visible": false,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_localizable"
],
"order": 8,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
},
{
"pk": 1896,
"attribute": {
"pk": 599,
"key": "density",
"data_type": "text",
"default_value": null,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"name": "density",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "density",
"pre_attribute": false,
"description": "Density"
},
"attribute_set": 116,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_localizable"
],
"order": 9,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z",
}
]
}
]
}

Search Atrribute Set

To get attribute set from the system, you can send the GET request. To filter, you can add parameters name and attribute_set_type as in QueryString. If you don't add parameter for filter, all attribute sets in the system will be returned.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
limitintegerbodyAmount of line items per page that will be returned
pageintegerbodyPage number to return
namestringbodyAttribute set's name.
attribute_set_typestringbodysimple or group

Request GET

Path: attribute_set/


import requests

url = "https://{customer_api_url}/api/i1/attribute_set/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

params = {
'name':'size',
'attribute_set_type' : 'simple',
'limit': 3,
'page': 1
}

response = requests.get(url, headers=headers , params=params)
print(response.text)

Response

Resource properties in Python format

PropertyData TypeDescription
namestringSet's name
attribute_set_typedictIt could be simple or group
valuestringAttribute set's value
labelstringAttribute set's label. It is used on the backoffice frontend.
attributeconfig_setarrayList of attributes included in the attribute set

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 512,
"name": "MPColorSize",
"attribute_set_type": {
"value": "simple",
"label": "Simple"
},
"attributeconfig_set": [
{
"pk": 1873,
"attribute": {
"pk": 665,
"key": "mp_color",
"data_type": "valuelabel",
"default_value": null,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": true,
"name": "MP Color",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_color",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": true,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 0,
"is_form_required": false,
"is_form_field_required": false
},
{
"pk": 1874,
"attribute": {
"pk": 666,
"key": "mp_size",
"data_type": "valuelabel",
"default_value": null,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": false,
"name": "MP Size",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_size",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": true,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": true,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 1,
"is_form_required": false,
"is_form_field_required": false
},
{
"pk": 1875,
"attribute": {
"pk": 667,
"key": "mp_filterable_color",
"data_type": "dropdown",
"default_value": 4035,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"name": "MP Filtrable Color",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_filterable_color",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 2,
"is_form_required": false,
"is_form_field_required": false
},
{
"pk": 1876,
"attribute": {
"pk": 668,
"key": "mp_filterable_size",
"data_type": "dropdown",
"default_value": 4042,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"name": "MP Filtrable Size",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_filterable_size",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": true,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 3,
"is_form_required": false,
"is_form_field_required": false
},
{
"pk": 1877,
"attribute": {
"pk": 669,
"key": "mp_description",
"data_type": "text",
"default_value": null,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": false,
"name": "MP Description",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_description",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 4,
"is_form_required": false,
"is_form_field_required": false
},
{
"pk": 1878,
"attribute": {
"pk": 670,
"key": "mp_gender",
"data_type": "dropdown",
"default_value": null,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": true,
"name": "MP Gender",
"is_form_required": false,
"is_form_field_required": false,
"erp_code": "mp_gender",
"pre_attribute": false,
"description": null
},
"attribute_set": 512,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": true,
"default_fields": [
"is_required",
"is_visible",
"is_searchable",
"is_filterable",
"is_variant",
"is_variant_listable",
"is_localizable",
"is_form_required",
"is_form_field_required"
],
"order": 5,
"is_form_required": false,
"is_form_field_required": false
}
]
}
]
}

Create Attribute Set

To add an attribute to an attribute set, the attribute set must first be created. After creating an attribute set, attributes can be added to the attribute set. Attribute set is used by grouping attributes. This way you can manage the same type of products with attribute sets, such as Phones, Televisions, etc.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account.
namestringbodySet's name.
attribute_set_typestringbodyIt could be simple or group

Request POST

POST request is used to create a new attribute set object.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

‘Accept-language’ header determines translatable fields responses.

Path:/v1/attribute_set/


import requests
import json

url = "https://{customer_api_url}/api/v1/attribute_set/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
'Accept-Language': 'en-us'
}

data = {
"attribute_set_type": "simple",
"name": "test_shirt_attribute_set"
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

Response

Returns the created attribute set. Successful response status is expected to be HTTP-201 Created.

Resource properties are in Python format.


{
"pk": 1108,
"name": "test_shirt_attribute_set",
"attribute_set_type": "simple",
"attributeconfig_set": [],
"description": null,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z,
}

Bad Request Responses

When the requested action cannot be executed, API gives an explanation about the request.

“name” is a unique field and cannot accept duplicate data.


{
"non_field_errors": "(name:test) already exists",
"error_code": "attribute_set_202_1"
}

Create Attribute Config

Attribute Configs are used for adding an attribute to the attribute set. You can configure attribute properties via AttributeConfig. For example, an attribute’s property ‘isfilterable’ is _True, and in an attribute set you want to make it False. You can do it by changing ‘is_filterable’ filter value while creating Attribute Config.

ParameterData TypeInRequiredDescription
api_tokenstringheaderYESThe API key of the customer account
attributeidbodyYESAttribute ID
attribute_setidbodyYESAttribute set ID
is_filterablebooleanbodyYES(default False) If the parameter is True, this attribute can be viewed in filters
is_requiredbooleanbodyYES(default False). It determines whether the attribute value can be left blank when creating or updating the product. If this parameter is True in the attribute set, this attribute must be required in the product
is_searchablebooleanbodyYES(default True) If the parameter is True, the customer can search with the value of the attribute on the website
is_variantbooleanbodyYES(default False) If the parameter is True for the size attribute, it is possible to make variants such as X size sweater, L size sweater among child products connected to the same parent product.
is_variant_listablebooleanbodyYES(default False) Determines whether different variants of the same product will appear on the product listing page
is_visiblebooleanbodyYES(default True) Determines whether the attribute will appear on the website. "_False” could be selected for attributes that will be used at the back office (Omnitron) and not used on the website. For example, ERP color code, ERP SKU, etc.
is_form_requiredbooleanbodyYES(default False) The customer needs to fill out a form when adding a product whose is_form_required value is True to the cart. Such as the name and note to be written on the jewelry, watches, wallets, flowers.
is_form_field_requiredbooleanbodyYES(default False) It determines whether the fields in the form (associated with "is_form_required”) shown to the customer are required
orderintegerbodyAttribute's order in the attribute set

Request POST

Attribute Configs are used for attributes in the Attribute Set. With Attribute Config attribute settings can be adjustable.

Path:/v1/attribute_config/


import requests
import json

url = "https://{customer_api_url}/api/v1/attribute_config/`"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
'Accept-Language': 'en-us'
}

data = {
"attribute": 668,
"attribute_set": 1108,
"is_filterable": False,
"is_required": False,
"is_searchable": True,
"is_variant": False,
"is_variant_listable": False,
"is_visible": True,
"is_form_required": False,
"is_form_field_required": False,
"order": 0
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

Response

Returns the created attribute config details.

{
"pk": 3383,
"attribute": 668,
"attribute_set": 1108,
"is_required": false,
"is_visible": true,
"is_searchable": true,
"is_filterable": false,
"is_variant": false,
"is_variant_listable": false,
"default_fields": [
"is_localizable"
],
"order": 0,
"is_form_required": false,
"is_form_field_required": false,
"modified_date": "2022-02-21T08:13:40.424413Z",
"created_date": "2016-12-14T14:56:02.160001Z,
}

Bad Request Responses

When the requested action cannot be executed, API gives an explanation about the request.

“attribute-attribute_set” is a unique field.



{
"non_field_errors": "(attribute:test) (attribute_set:test) already exists",
"error_code": "attribute_set_203_1"
}

If an attribute is a variant attribute, it cannot be in a custom attribute set.


{
"non_field_errors": "Attribute config custom attribute set validation error. Custom attribute set doesn't accept variant attribute",
"error_code": "attribute_set_203_3"
}

An attribute cannot be in both a custom attribute set and an attribute set.


{
"non_field_errors": "This attribute cannot exist in custom attribute set and attribute set",
"error_code": "attribute_set_203_4"
}