|
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:
- Retrieve all existing list values from Quable PIM and compare them with those in your ERP.
- 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
| |
HTTP Method | GET | ||
Query Parameters | |||
attribute.id | string | The unique identifier of the predefined value. | |
attribute.id[] | array(string) | Array of unique identifiers(attribute.id ) of multiple predefined values. | |
page | integer | The collection page number. | |
limit | integer | The number of items per page. | |
pagination | boolean |
|
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-values | API v4 endpoint | |
HTTP Method | POST | ||
Query Parameters | |||
targetCulture | string | Code of the data locale. | |
Request Body | |||
Required Attributes | code | string | The unique identifier of the predefined value. |
eav_attribute_code | string | Unique code of the attribute to which the predefined value is associated. | |
value | string | The value to add. | |
Accepted Attributes | description | string | 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 Method | PUT | ||
Query Parameters | |||
code | integer | The unique code of the predefined value to update | |
targetCulture | string | Code of the data locale. | |
Request Body | |||
Required Attributes | code | string | Unique code of the predefined value to update. |
eav_attribute_code | string | Unique code of the attribute to which the predefined value is associated. | |
value | string | The edited value. | |
Accepted Attributes | description | string | A 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)