Skip to content

Commit b6110d1

Browse files
committed
save
1 parent b285355 commit b6110d1

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource.md

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Imagine managing inventory across multiple locations effortlessly. Commerce Exte
99
In this guide you will learn how to:
1010

1111
* Create a Custom API to store your location inventory data.
12-
* Streamline your data import and sync processes using upserts and accessing entries with well-known identifiers.
1312
* Ensure the accuracy of your inventory amounts using Conditional Updates to prevent lost updates and other data conistency issues.
1413

1514
## Prerequisites
@@ -35,13 +34,12 @@ curl -X POST "https://useast.api.elasticpath.com/v2/settings/extensions/custom-a
3534
"api_type": "location-inventories_ext",
3635
"name": "Location Inventories",
3736
"description": "Inventory entries for all SKUs at all retail locations.",
38-
"allow_upserts": true,
3937
"type": "custom_api"
4038
}
4139
}
4240
```
4341

44-
Make sure to take note of the Custom API ID [returned](/docs/api/commerce-extensions/create-a-custom-api#responses), you must replace `:customApiId` in the following step with the Custom API ID. In addition, notice that `data.allow_upserts` is set to `true`, this allows to perform [upserts](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#update-custom-api-entries) of Custom API Entries.
42+
Make sure to take note of the Custom API ID [returned](/docs/api/commerce-extensions/create-a-custom-api#responses), you must replace `:customApiId` in the following step with the Custom API ID.
4543

4644
## Create Custom Fields
4745

@@ -133,6 +131,7 @@ curl -X POST "https://useast.api.elasticpath.com/v2/settings/extensions/custom-a
133131
}
134132
}
135133
```
134+
136135
Take note of `data.validation.string` in the step above, this field is restricted to only allow the following values:
137136
* Paris
138137
* London
@@ -185,25 +184,7 @@ curl -X PUT "https://useast.api.elasticpath.com/v2/extensions/location-inventori
185184
}
186185
```
187186

188-
Notice that the resource identifier in the request above is one that should be well-known to you and your processes and not a random UUID generated by the platform `/v2/extensions/location-inventories/:customApiEntryId`. Because [earlier](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-custom-field---slug) you made `sku` unique and case-insensive requests using a value like `tbl-din-6Wd-oak-0034` and every variation like it using different casing will update the same resource.
189-
190-
## Upsert Custom API Entries
191-
192-
To further simplify and optimize your data import and synchronization processes you can upsert Custom API Entries. Instead of first having to check whether a record exists and then deciding to create or update a Custom API Entries, you can upsert a record, if it exists it is updated, and if it doesn't, then it is inserted or created. This is made possible by your setting of `data.allow_upserts` when you [created this Custom API](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-a-new-custom-api---location-inventories).
193-
194-
```sh
195-
curl -X PUT "https://useast.api.elasticpath.com/v2/extensions/location-inventories/FURN-SOFA-3S-LTH-BLK-0021" \
196-
-H "Authorization: XXXX" \
197-
-H "Content-Type: application/json" \
198-
-d ${
199-
"data": {
200-
"sku": "FURN-SOFA-3S-LTH-BLK-0021",
201-
"type": "location_inventory_ext",
202-
"amount": 12,
203-
"location-name": "Paris"
204-
}
205-
}
206-
```
187+
Notice that the resource identifier in the request above is one that should be well-known to you and your processes and not a random UUID generated by the platform `/v2/extensions/location-inventories/:customApiEntryId`. [Earlier](/guides/How-To/commerce-extensions/create-a-multilocation-inventories-resource#create-custom-field---slug) you made `sku` unique and case-insensive, so requests using a value like `tbl-din-6Wd-oak-0034` and similar varations using different casing will update, retrieve and potentially delete the same resource.
207188

208189
## Conditional Updates
209190

@@ -247,4 +228,4 @@ curl -X GET "https://useast.api.elasticpath.com/v2/extensions/location-inventori
247228
-H "Authorization: XXXX" \
248229
```
249230

250-
For more information, see [Filtering](/docs/api/commerce-extensions/get-all-custom-entries#filtering).
231+
For more information, see [Filtering](/docs/api/commerce-extensions/get-all-custom-entries#filtering).

0 commit comments

Comments
 (0)