1. Predefined Values

120

🚧

Prerequisite

Predefined values for selection lists must be imported before you can import your objects (classifications, documents, variants, assets) into Quable PIM.

Use Case

You have a document to import from your ERP with the brand attribute (a simple selection list of predefined values).

In order to import the document object, the brand attribute's predefined values must already be available in Quable PIM. In other words, the values must be imported before the document object.

There are two steps to ensure that the predefined values are available for your selection list attributes:

  1. Retrieve all existing list values from Quable PIM and compare them with those in your ERP.
  2. Add / modify values as necessary in Quable PIM.



Retrieve Existing Predefined Values

To retrieve all list values, you can send the request without any attributes.

To retrieve the list values for a specific attribute, you must include the attribute's code.

URL Parameters
Endpoint/predefined-values

Note: To retrieve the values for a specific attribute, you must include the attribute's code: /predefined-values?attribute.id={{code}}
API v5 endpoint

📘

This endpoint provides a paginated list of predefined values.

HTTP MethodGET
Query Parameters
attribute.idstringThe unique identifier of the predefined value.
attribute.id[]array(string)Array of unique identifiers(attribute.id) of multiple predefined values.
pageintegerThe collection page number.
limitintegerThe number of items per page.
paginationboolean
  • If True, pagination is enabled.
  • If False, pagination is disabled.

Example

This example is a call to retrieve the list of values for the brand attribute:

import requests
import json

url = "https://{{YOUR-PIM}}.quable.com/api/predefined-values?attribute.id=brand"

payload={}
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer xxx'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

The JSON response allows you to compare the data from your ERP to the data already present in Quable PIM:

{
  "@context": "/api/contexts/PredefinedValue",
  "@id": "/api/predefined-values",
  "@type": "hydra:Collection",
  "hydra:member": [
    {
      "@id": "/api/predefined-values/attribute=brand;code=quable_brand",
      "attribute": {
        "@id": "/api/attributes/brand",
        "id": "brand"
      },
      "name": {
        "en_GB": "Quable",
        "fr_FR": "Quable"
      },
      "dateCreated": "2021-02-16T15:59:11+00:00",
      "dateModified": "2021-02-16T15:59:11+00:00",
      "id": "attribute=brand;code=quable_brand"
    },
    {
      "@id": "/api/predefined-values/attribute=brand;code=elbauq",
      "attribute": {
        "@id": "/api/attributes/brand",
        "id": "brand"
      },
      "name": {
        "en_GB": "Elbauq",
        "fr_FR": "Elbauq"
      },
      "dateCreated": "2021-02-16T15:59:11+00:00",
      "dateModified": "2021-02-16T15:59:11+00:00",
      "id": "attribute=brand;code=elbauq"
    }
  ],
  "hydra:totalItems": 2,
   ...
}



Create New Predefined Values

To create new predefined values, you must know the values to create, as well as the attribute to which the value(s) are added.

URL Parameters
Endpoint/api_1.php/eav-valuesAPI v4 endpoint
HTTP MethodPOST
Query Parameters
targetCulturestringCode of the data locale.
Request Body
Required Attributescodestring The unique identifier of the predefined value.
eav_attribute_codestring Unique code of the attribute to which the predefined value is associated.
valuestring The value to add.
Accepted Attributesdescriptionstring A description of the predefined value.

Example

import requests
import json

url = "https://{{YOUR-PIM}}.quable.com/api_1.php/eav-values"

payload = json.dumps({
  "eav_attribute_code": "brand",
  "code": "brand_new",
  "value": "New brand",
  "description": "This is a new brand from the ERP"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ...'
}

response = requests.request("POST", url, headers=headers, data=payload)



Edit Predefined Values

To modify an attribute's predefined values, you must specify the code of the attribute whose value(s) you want to change.

URL Parameters
Endpoint/api_1.php/eav-values/{{code}}

Note: {{code}} is the unique code of the predefined value to update
API v4 endpoint
HTTP MethodPUT
Query Parameters
codeintegerThe unique code of the predefined value to update
targetCulturestringCode of the data locale.
Request Body
Required AttributescodestringUnique code of the predefined value to update.
eav_attribute_codestringUnique code of the attribute to which the predefined value is associated.
valuestringThe edited value.
Accepted AttributesdescriptionstringA description of the predefined value.

Example

import requests
import json

url = "https://{{YOUR-PIM}}.quable.com/api_1.php/eav-values/{{code}}?targetCulture=fr_FR"

payload = json.dumps({
  "code": "brand_new",
  "value": "Nouvelle marque",
  "description": "Ceci est la description de la nouvelle marque en Français"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ...'
}

response = requests.request("PUT", url, headers=headers, data=payload)