Skip to content

Commit 07c1ac5

Browse files
authored
Merge pull request #306 from AdobeDocs/DCAT-2640-merge-attributes
DCAT-2640: Allow merge strategy for array-type fields
2 parents 7ecfd33 + 2f110d8 commit 07c1ac5

File tree

1 file changed

+55
-64
lines changed

1 file changed

+55
-64
lines changed

static/rest/data-ingestion-schema-v1.yaml

Lines changed: 55 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,16 @@ paths:
10791079
description: |
10801080
Update products with specified `sku` and `source` values to replace existing field data with the data supplied in the request.
10811081
When the update is processed, the merge strategy is used to apply changes to `scalar` and `object` type fields.
1082-
The replace strategy is used to apply changes for fields in an `array`.
1082+
1083+
For `array` type fields, a new value can be appended to the existing list. For an object list, you can update a specific object by matching on a key field. The following fields are supported:
1084+
* `attributes` - match on `code`
1085+
* `images` - match on `url`
1086+
* `routes` - match on `path`
1087+
* `links` - match on `type` and `sku`
1088+
* `bundles` match on `type` and `group`
1089+
* `configurations` match on `type` and `attributeCode`
1090+
* `externalIds` match on `type` and `origin`
1091+
10831092
operationId: updateProducts
10841093
parameters:
10851094
- $ref: "#/components/parameters/Authorization"
@@ -1114,25 +1123,13 @@ paths:
11141123
In the example below, the following attributes are updated.
11151124
* `name` - Change the product name.
11161125
* `metaTags.title` - Change the title of the product detail page.
1117-
* `attributes` - Add a new state, `NM` to the `states` attribute.
11181126
value:
11191127
[
11201128
{
11211129
"sku": "red-pants",
11221130
"source": { "locale": "en-US" },
11231131
"name": "Red pants - discounts!",
1124-
"metaTags": { "title": "Updated - Red" },
1125-
"attributes":
1126-
[
1127-
{
1128-
"code": "cost",
1129-
"values": ["10.5"]
1130-
},
1131-
{
1132-
"code": "states",
1133-
"values": ["TX", "CA", "NM"]
1134-
}
1135-
]
1132+
"metaTags": { "title": "Updated - Red" }
11361133
}
11371134
]
11381135
UnassignProductVariant:
@@ -1166,6 +1163,7 @@ paths:
11661163
summary: Add a new item `gloves` to the accessories group of the bundle product `bundle-outfit`
11671164
description: |
11681165
To add a new item `gloves` to the accessories group of the bundle product `bundle-outfit`, include the new item in the `items` array of the `accessories` group.
1166+
The previously created items `socks` and `headband` should be retained in the updated bundle.
11691167
Note that simple product `gloves` must be created separately using the create product API.
11701168
value:
11711169
[
@@ -1174,44 +1172,6 @@ paths:
11741172
"source": { "locale": "en-US" },
11751173
"bundles":
11761174
[
1177-
{
1178-
"group": "tops",
1179-
"required": true,
1180-
"multiSelect": false,
1181-
"defaultItemSkus": ["top-red"],
1182-
"items":
1183-
[
1184-
{
1185-
"sku": "top-red",
1186-
"qty": 1,
1187-
"userDefinedQty": false
1188-
},
1189-
{
1190-
"sku": "top-blue",
1191-
"qty": 1,
1192-
"userDefinedQty": false
1193-
}
1194-
]
1195-
},
1196-
{
1197-
"group": "bottoms",
1198-
"required": true,
1199-
"multiSelect": false,
1200-
"defaultItemSkus": ["bottom-black"],
1201-
"items":
1202-
[
1203-
{
1204-
"sku": "bottom-black",
1205-
"qty": 1,
1206-
"userDefinedQty": false
1207-
},
1208-
{
1209-
"sku": "bottom-white",
1210-
"qty": 1,
1211-
"userDefinedQty": false
1212-
}
1213-
]
1214-
},
12151175
{
12161176
"group": "accessories",
12171177
"required": false,
@@ -1238,6 +1198,35 @@ paths:
12381198
]
12391199
}
12401200
]
1201+
AddNewAttributeAndReplaceExisting:
1202+
summary: Add a new attribute and replace existing one
1203+
description: |
1204+
Add a new attribute `warehouse`, and update the value of the existing `cost` attribute for the simple product `red-pants`
1205+
1206+
In the example below:
1207+
* A new attribute with the code `warehouse` is added to the attributes list
1208+
* The value of the existing `cost` attribute is replaced with new value
1209+
1210+
The previously created `states` attribute is preserved.
1211+
Note: Don't forget to create the product attribute metadata (<a href="#operation/createProductMetadata">link</a> for the `warehouse` attribute if it doesn't exist yet.
1212+
value:
1213+
[
1214+
{
1215+
"sku": "red-pants",
1216+
"source": { "locale": "en-US" },
1217+
"attributes":
1218+
[
1219+
{
1220+
"code": "warehouse",
1221+
"values": [ "Austin" ]
1222+
},
1223+
{
1224+
"code": "cost",
1225+
"values": ["12"]
1226+
}
1227+
]
1228+
}
1229+
]
12411230
/v1/catalog/products/delete:
12421231
post:
12431232
tags:
@@ -1820,13 +1809,17 @@ paths:
18201809
description: |
18211810
Change existing product prices, discounts, and tiered pricing.
18221811
1823-
When the update is processed, the merge strategy is used to apply changes to `scalar` and `object` type fields. The replace strategy is used to apply changes for fields in an `array`.
1812+
When the update is processed, the merge strategy is used to apply changes to `scalar` and `object` type fields.
1813+
1814+
For `array` type fields, a new value can be appended to the existing list. For an object list, you can update a specific object by matching on a key field. The following fields are supported:
1815+
* `discounts` - match on `code`
1816+
* `tierPrices` - match on `qty`
18241817
18251818
<h3>Update strategies</h3>
18261819
18271820
* **Regular Price** - Updated using merge strategy
1828-
* **Discounts Array** - Updated using replace strategy (entire array is replaced)
1829-
* **Tiered Pricing Array** - Updated using replace strategy (entire array is replaced)
1821+
* **Discounts Array** - Updated using the append or merge strategy
1822+
* **Tiered Pricing Array** - Updated using the append or merge strategy
18301823
18311824
<h3>Discount and tier pricing updates</h3>
18321825
@@ -1872,19 +1865,21 @@ paths:
18721865
summary: Update product prices with enhanced discounts and tiered pricing
18731866
description: |
18741867
Update existing product prices for the given SKU ("red-pants") and price book id ("dealer-north").
1875-
This example shows how to update both discounts and tiered pricing simultaneously.
1868+
This example shows how to update both discounts and tiered pricing simultaneously:
1869+
* **discounts**: Update the existing `seasonal_sale` discount and add a new `holiday_sale` discount
1870+
* **tierPrices**: Update the existing percentage discount for quantity 5 and add a new discount for quantity 20
18761871
value:
18771872
[
18781873
{
18791874
"sku": "red-pants",
18801875
"priceBookId": "dealer-north",
18811876
"discounts": [
18821877
{
1883-
"code": "holiday_sale",
1878+
"code": "seasonal_sale",
18841879
"percentage": 30
18851880
},
18861881
{
1887-
"code": "bulk_discount",
1882+
"code": "holiday_sale",
18881883
"price": 5.00
18891884
}
18901885
],
@@ -1894,12 +1889,8 @@ paths:
18941889
"percentage": 20
18951890
},
18961891
{
1897-
"qty": 10,
1898-
"percentage": 40
1899-
},
1900-
{
1901-
"qty": 25,
1902-
"price": 12.00
1892+
"qty": 20,
1893+
"price": 13
19031894
}
19041895
]
19051896
}

0 commit comments

Comments
 (0)