Skip to main content

Product Attributes and Values

Principle of Operation

Attributes allow for storing various characteristics and properties of products in Sailplay: composition, weight, color, seasonality, etc.

Attributes vary by attribute type and value type.

Attribute Types

  • Single-value Attribute — a one-to-one relationship between products and values: each product can have no more than one value for each attribute.

    • Suitable for mutually exclusive properties: product availability, model year, color (if you know for sure that a product can only have one color).
  • Multi-value Attribute — a one-to-many relationship between products and values: one product can have multiple values for an attribute simultaneously.

    • Suitable for complex characteristics: composition, authorship, and any cases where a product can have multiple values.

Value Types

  • Text — any strings can be stored. Suitable for most characteristics.
  • Number — only a number can be stored (negative and fractional values are possible).

The main difference between text and numeric values is indexing and search. Unlike strings, for numeric values, you can perform selection by range, not just by strict match.

Important

Only those characteristics that unambiguously relate to all products with this SKU should be stored in attributes.

If several product variants with different characteristics (e.g., size) are sold under one SKU, it is better to pass such characteristics in purchase parameters, rather than in SKU attributes.


Creating and Editing Product Attributes

When creating product attributes, use the /api/v2/basket/attributes/add/ method (see ref:basket-attributes-add).

In the request, in addition to application authorization data, you must specify:

  • sku — technical name of the attribute (internal identifier in your system)
  • other attribute parameters (type, title, etc.)

To edit, use /api/v2/basket/attributes/edit/ (see ref:basket-attributes-edit).

Important

When editing an attribute, it is possible to change its type from single-value to multi-value, but not vice versa.

To get a list of all created attributes and their values, use the /api/v2/basket/attributes/list/ method (see ref:basket-attributes-list).

Only token and store_department_id are required in the request (see Authorization). If the attribute sku is passed, information only for it will be returned in the response.


Attribute Values

API methods for working with attribute values allow you to:

  • create values
  • edit values
  • get a list of values

In requests, you must pass:

  • value_skuvalue SKU
  • attribute_skuattribute SKU to which the value belongs

Unlike attributes, values can be deleted via the /api/v2/basket/attributes/values/delete/ method (see ref:basket-attributes-values-delete).


Assigning Attributes and Values to Products

To assign an attribute and value to a product previously loaded into the system, use the /api/v2/basket/products/attributes/add/ method (see ref:basket-products-attributes-add).

In the request, you need to pass:

  • product_sku — product SKU
  • attribute_sku — attribute SKU
  • value_sku — value SKU

To change an attribute value for a product, use the /api/v2/basket/products/attributes/edit/ method (see ref:basket-products-attributes-edit).

The following are passed in the request:

  • value_sku_from — current value SKU
  • value_sku_to — new value SKU

To delete an attribute assigned to a product, use /api/v2/basket/products/attributes/delete/ (see ref:basket-products-attributes-delete).