Step: 5 Import Composite Data
Composites model complex, repeating groups of attributes. These are allowed to nest 1..many levels deep.
Prerequisite: Create the Attribute Definitions
Unlike flat attributes, composites must be defined in the PDX datastandard before you can import product data into them. Use the following endpoint to create both the child attributes and the parent composite container.
PUT /api/datastandards/v1/datastandards/attributes
Example Composite Attribution Creation Payload:
[
{
"id": "AllergenInformation/AllergenType",
"externalId": "AllergenType",
"name": "Allergen Type",
"description": "Allergen Type Code",
"type": {
"id": "string",
"restriction": {
"parameters": {},
"listOfValues": [],
"patterns": []
},
"isFamily": false,
"multiValue": true,
"units": [],
"clientSpecificListOfValues": null,
"languages": null,
"lockedByOverride": false
},
"attributeLinks": [],
"groupIds": [],
"disableSubmitInStates": [],
"metadata": []
},
{
"id": "AllergenInformation",
"externalId": "AllergenInformation",
"name": "Allergen Info",
"description": "Composite to hold allergen attribution",
"type": {
"id": "composite",
"restriction": {
"parameters": {},
"listOfValues": [],
"patterns": []
},
"isFamily": false,
"multiValue": true,
"units": [],
"clientSpecificListOfValues": null,
"languages": null,
"lockedByOverride": false
},
"attributeLinks": [
{
"id": "AllergenInformation/AllergenType",
"optional": true,
"initRequired": false,
"appliesTo": "ALL",
"datastandardPattern": null,
"datastandardPatternExample": null,
"listOfValuesFilter": [],
"defaultValue": null
}
],
"groupIds": [],
"disableSubmitInStates": [],
"metadata": []
}
]Note that the parent composite needs to be set to
multiValue=trueto allow for multiple rows.
After the composite and composite attribution has been created, you can begin loading the composite data within the existing product import feed:
Example Composite Payload:
{
"products": [
{
"__ID": "WIDGET-100",
"AllergenInformation": [
{
"AllergenType": "Peanuts",
"Containment": "Does Not Contain",
"Agency": "USDA"
},
{
"AllergenType": "Dairy",
"Containment": "May Contain",
"Agency": "EFSA"
}
]
}
]
}