Attributes

16. jaanuar 2023


Attributes

The simplest way to extend product records is to attach attributes. Attributes are just arbitrary key-value pairs; you can make up an attribute name on the spot.
The value of an attribute can be a string, an integer or a floating-point value.
Interacting with attributes in Erply API generally looks as follows. You can attach or update attributes when saving a record:

clientCode:{{clientCode}}
sessionKey:{{sessionKey}}
request:saveProduct
sendContentType:1
code:75
code2:9780385535144
name:THE RACKETEER, by John Grisham

attributeName1:binding
attributeType1:text
attributeValue1:Hardcover

attributeName2:number_of_pages
attributeType2:int
attributeValue2:352

The attributes are returned from a "get" call:

{
    "status": {
        "request": "getProducts",
        ...
    },
    "records": [
        {
            "productID": 162,
            "name": "THE RACKETEER, by John Grisham",
            ...
            "attributes": [
                {
                    "attributeName": "binding",
                    "attributeType": "text",
                    "attributeValue": "Hardcover"
                },
                {
                    "attributeName": "number_of_pages",
                    "attributeType": "int",
                    "attributeValue": "352"
                }
            ]
        }
    ]
}

Lookup by attribute, or by a combination of multiple attributes, is supported:

sessionKey:{{sessionKey}}
clientCode:{{clientCode}}
request:getProducts
sendContentType:1
searchAttributeName1:binding
searchAttributeValue1:Hardcover

In Erply API, attribute support is implemented in API calls getProducts and saveProduct. Many other API calls have the same feature, too. If a call supports attributes, it is mentioned in its input/output documentation.

PIM API contains the calls GET ​/v1​/attribute (for retrieving a product's attributes), PUT ​/v1​/attribute (for adding or modifying an attribute) and DELETE​ /v1​/attribute​/{ids} (for removing attributes). Product lookup by attribute value is not implemented yet, but is on the roadmap.

Attributes are also visible and editable in back office, on the “Attributes" tab on the product card (in both the new PIM and the older product catalog).

Caveats:

  • Text attributes are limited to 255 characters in length.
  • Heavy use (storing hundreds of thousands of attributes) might degrade account performance.

Long Attributes

Long attributes have a higher maximum length (support storing 65,000 characters, instead of 255), but are not visible and editable in back office. 

Long attributes are only accessible over Erply API (in saveProduct and getProducts calls).