The following four items will be discussed within the scope of product attributes.
Attribute
AttributeSet
AttributeConfig
AttributeValue
During the initial installation of Omnitron, product attributes, namely Attribute values, are created before the products themselves. AttributeSet values are created to keep these attribute values together. AttributeConfigs are then added to link Attributes and AttributeSets. Attributes and AttributeSets are linked completely through AttributeConfig, as there is no direct relation between them. Finally, an AttributeValue is added for each Attribute.
1. Attribute
Indicates product attributes. Product properties, such as size, color, etc. are called Attributes. Attributes AttributeInputTypes {omnicore.products.enums.AttributeInputTypes} can have the following types: text, boolean, dropdown etc. Attribute values of products not productized are controlled with the pre_attribute: bool value, while the attribute values of a product marked as pre_product will be pre_attibute=True. Attribute objects are multilingual and can be localized.
2. AttributeSet
Multiple Attributes form an AttributeSet. For example, the size and color of a product created for clothing will be the AttributeSet collectively belonging to the clothing products. AttributeSet may be of two different types: simple and grouped, as specified in AttributeSetType {omnicore.products.enums.AttributeSetTypes}.
3. AttributeConfig
AttributeConfig is a bridge between Attribute and AttributeSet, and singular between the two properties. It means that there can only be one AttributeConfig between Attribute and AttributeSet.
4. AttributeValue
Values of the product’s attributes. If a garment size is Attribute, sizes such as X, M, L and XL are AttributeValue. AttributeValue objects are multilingual and can be localized.
GET Attributes
Path: /api/v1/attributes/
Brings the attribute values from the Attribute table. Gets the filter parameters with {omnitron.products.resources.filters.AttributeFilter} in AttributeFilter as query parameters. Supports pagination with ViewSet’s inheritance from ListModelMixin with query parameters of page=X and limit=Y.
AttributeFilter
Used in listing operations with GET used in AttributeViewSet. It can get the following parameters as a filter.
Adds a new record to the Attribute table. It is validated with AttributeSerializer. If the data is not suitable, it returns HTTP400. If there is an error or non-compliance in the service layer during the recording process, it returns HTTP406.
Partially updates the object of the relevant primary key from the Attribute table. It is validated with AttributeSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With a partial update behavior, it only updates the sent parameters.
{
"key": [
"You can only use lowercase and uppercase letters in English alphabet, digits and underscores."
]
}
-- OR
{
"data_type": [
"No matching type."
]
}
-- OR
{
"non_field_errors": "Data Type can not be updated.",
"error_code": "attribute_200_5"
}
-- OR
{
"non_field_errors": [
"is_localizable field cannot be True when Attribute data_type is not one of text or text_area."
]
}
PUT Update Attribute
Path: /api/v1/attributes/{pk}/
Updates the object of the relevant primary key from the Attribute table. It is validated with AttributeSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With an update behavior, it updates the entire object.
GET Attributes Details
Path: /api/v1/attributes/detailed/
Exhibits the same behavior as Attribute listing, but the return parameters are more detailed. The data_type and visible_values fields are retrieved in detail.
Exhibits the same behavior as getting Attributes, but the return parameters are more detailed. The data_type and visible_values fields are retrieved in detail.
Brings the attribute values from the AttributeSet table. Gets the filter parameters in AttributeSetFilter {omnitron.products.resources.filters.AttributeSetFilter} as query parameters. Supports pagination with ViewSet’s inheritance from ListModelMixin with query parameters of page=X and limit=Y.
AttributeSetFilter
Used in listing operations with GET used in AttributeSetViewSet. It can get the following parameters as a filter.
Adds a new record to the AttributeSet table. It is validated with AttributeSetSerializer. If the data is not suitable, it returns HTTP400. If there is an error or non-compliance in the service layer during the recording process, it returns HTTP406.
Partially updates the object of the relevant primary key from the AttributeSet table. It is validated with AttributeSetSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With a partial update behavior, it only updates the sent parameters.
{
"name": [
"attribute set with this name already exists."
]
}
PUT Update Attribute Set
Path: /api/v1/attribute_set/{pk}/
Updates the object of the relevant primary key from the AttributeSet table. It is validated with AttributeSetSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With an update behavior, it updates the entire object.
{
"attribute_set_type": [
"This field is required."
]
}
GET Attribute Sets Details
Path: /api/v1/attribute_set/detailed/
Exhibits the same behavior as AttributeSet listing, but the return parameters are more detailed. It also gets individual Attribute values in "attributeconfig_set."
Exhibits the same behavior as getting AttributeSets, but the return parameters are more detailed. It also gets individual Attribute values in "attributeconfig_set."
Gets the values in the AttributeConfig table. Gets the filter parameters with {omnitron.products.resources.filters.AttributeConfigFilter} in AttributeConfigFilter as query parameters. Supports pagination with ViewSet’s inheritance from ListModelMixin with query parameters of page=X and limit=Y.
AttributeConfigFilter
Used in listing operations with GET used in AttributeConfigViewSet. It can get the following parameters as a filter.
attribute: pk value of the relevant Attribute object.
attribute_set: pk value of the relevant AttributeSet object.
Adds a new record to the AttributeConfig table. It is validated with AttributeConfigSerializer. If the data is not suitable, it returns HTTP400. If there is an error or non-compliance in the service layer during the recording process, it returns HTTP406.
{
"attribute": [
"Invalid pk \"995\" - object does not exist."
],
"attribute_set": [
"Invalid pk \"842\" - object does not exist."
]
}
-- OR
{
"code": "attribute_config_203_5",
"en": "Multiple type attribute cannot assign to an attribute set"
}
-- OR
{
"non_field_errors": [
"The fields attribute, attribute_set must make a unique set."
]
}
-- OR
{
"code": "attribute_config_203_3",
"en": "Attribute config custom attribute set validation error. Custom attribute set doesn't accept variant attribute"
}
-- OR
{
"code": "attribute_config_203_4",
"en": "This attribute cannot exist in custom attribute set and attribute set"
}
DELETE Attribute Config
Path: /api/v1/attribute_config/{pk}/
Deletes the object of the relevant primary key from the AttributeConfig table. If it cannot find the object, it returns HTTP404.
Response: HTTP204
GET Attribute Config
Path: /api/v1/attribute_config/{pk}/
Gets the object of the relevant primary key from the AttributeSet table. If it cannot find the object, it returns HTTP404.
Partially updates the object of the relevant primary key from the AttributeConfig table. It is validated with AttributeConfigSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With a partial update behavior, it only updates the sent parameters.
{
"attribute_set": [
"Invalid pk \"700\" - object does not exist."
]
}
-- OR
{
"attribute": [
"Invalid pk \"10000\" - object does not exist."
]
}
-- OR
{
"non_field_errors": [
"The fields attribute, attribute_set must make a unique set."
]
}
-- OR
{
"non_field_errors": "Attribute config custom attribute set validation error. Custom attribute set doesn't accept variant attribute",
"error_code": "attribute_config_203_3"
}
PUT Update Attribute Config
Path /api/v1/attribute_config/{pk}/
Updates the object of the relevant primary key from the AttributeConfig table. It is validated with AttributeConfigSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With an update behavior, it updates the entire object.
{
"is_visible": [
"This field is required."
],
"is_variant_listable": [
"This field is required."
],
"attribute": [
"This field is required."
],
"is_form_required": [
"This field is required."
],
"is_filterable": [
"This field is required."
],
"is_searchable": [
"This field is required."
],
"is_form_field_required": [
"This field is required."
],
"attribute_set": [
"This field is required."
],
"is_required": [
"This field is required."
]
}
GET Attribute Configs Details
Path: /api/v1/attribute_config/detailed/
Exhibits the same behavior as AttributeSet listing, but the return parameters are more detailed. Gets the associated attribute value in detail.
Gets the values in the AttributeValue table. Gets the filter parameters in AttributeValueFilter {omnitron.products.resources.filters.AttributeValueFilter} as query parameters. Supports pagination with ViewSet’s inheritance from ListModelMixin with query parameters of page=X and limit=Y.
AttributeValueFilter
Used in listing operations with GET used in AttributeValueViewSet. It can get the following parameters as a filter.
label: The title field for the AttributeValue. It only needs to contain this value and works as case-sensitive.
erp_code: The erp code field for the AttributeValue. It only needs to contain this value.
value: The value field for the AttributeValue. It only needs to contain this value.
value__exact: The value field for the AttributeValue. It requires a complete match.
attribute: pk value of the relevant Attribute object.
Adds a new record to the AttributeValue table. It is validated with AttributeValueSerializer. If the data is not suitable, it returns HTTP400. If there is an error or non-compliance in the service layer during the recording process, it returns HTTP406.
{
"attribute": [
"Invalid pk \"995\" - object does not exist."
]
}
-- OR
{
"non_field_errors": [
"The fields attribute, value must make a unique set."
]
}
-- OR
{
"non_field_errors": "... already exists",
"error_code": "attribute_value_201_1"
}
GET Attribute Value
Path: /api/v1/attribute_value/{pk}/
Gets the object of the relevant primary key from the AttributeValue table. If it cannot find the object, it returns HTTP404.
Partially updates the object of the relevant primary key from the AttributeValue table. It is validated with AttributeValueSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With a partial update behavior, it only updates the sent parameters.
{
"non_field_errors": "... already exists",
"error_code": "attribute_value_201_1"
}
-- OR
{
"non_field_errors": ""AttributeValue can not be updated."",
"error_code": "attribute_value_201_2"
}
PUT Update Attribute Value
Path: /api/v1/attribute_value/{pk}/
Updates the object of the relevant primary key from the AttributeValue table. It is validated with AttributeValueSerializer. If the data is not suitable, it returns HTTP400. If it cannot find the object, it returns HTTP404. With an update behavior, it updates the entire object.