There are a few options to extend the Sitecore commerce entities, OOTB Sitecore XC provided below entities.
- Sitecore.Commerce.Plugin.Catalog.SellableItem
- Sitecore.Commerce.Plugin.Catalog.Catalog
- Sitecore.Commerce.Plugin.Catalog.Category
- Sitecore.Commerce.Plugin.Promotions.PromotionBook
- Sitecore.Commerce.Plugin.Promotions.Promotion
- Sitecore.Commerce.Plugin.Pricing.PriceBook
- Sitecore.Commerce.Plugin.Pricing.PriceCard
- Sitecore.Commerce.Plugin.Customers.Customer
- Sitecore.Commerce.Plugin.Orders.Order
If you are working in the commerce world, you will see a requirement to extend these entities, the requirement can be an example below.
1, Add invoice link to the order - Add a new field on order entities to show the invoice link or status from the backend system.
2. Add a new field on customer entities to show the preferred time for the call, Membership type like gold, silver etc.
3. Extend the sellable item (The most common one) to add more fields like custom properties for Color, notes etc.
For updating the order usually, we should use the minion jobs to read the current status and update from the backend system but sometimes you need to update those details from the outer side. Here are a few easy tips.
To update any field values of entities like Order, Customer you can use the GetEntityVIew to get the Entry and
URL will be like this
https://commerceauthoring.XX.dev.com/api/GetEntityView()- h
Request input-
{
"entityId": "Entity-Customer-f26e9063ba38461bafcf97fe4a115830",
"viewName": "EditView",
"forAction": "EditView",
"itemId": "Composer-82bd424ddb274945912dca6fb71cea4b"
}
We need to pass the Customer or Entity and name of the Composer template- {
"@odata.context": "https://commerceauthoring.XXX.com.dev.com/Api/$metadata#Sitecore.Commerce.EntityViews.EntityView",
"@odata.type": "#Sitecore.Commerce.EntityViews.EntityView",
"Name": "EditView",
"Policies": [
],
"DisplayName": "Edit View",
"EntityId": "Entity-SellableItem-demohandtowel1",
"EntityVersion": 4,
"Action": "EditView",
"ItemId": "Composer-82bd424ddb274945912dca6fb71cea4b",
"VersionedItemId": "Composer-82bd424ddb274945912dca6fb71cea4b-4",
"SelectedChildView": {
"Name": "",
"Policies": [
]
},
"DisplayRank": 500,
"UiHint": "Flat",
"Icon": "chart_column_stacked",
"Properties": [
{
"Name": "Version",
"Policies": [
],
"DisplayName": "Version",
"Value": "1",
"IsHidden": true,
"OriginalType": "System.Int32",
"IsReadOnly": true,
"UiType": "",
"IsRequired": true
},
{
"Name": "LaunchDate",
"Policies": [
],
"DisplayName": "Launch Date",
"Value": "2020-09-16T14:26:00.5386742+00:00",
"IsHidden": false,
"OriginalType": "System.DateTimeOffset",
"IsReadOnly": false,
"UiType": "",
"IsRequired": true
},
{
"Name": "DealerName",
"Policies": [
],
"DisplayName": "Dealer Name",
"Value": "",
"IsHidden": false,
"OriginalType": "System.String",
"IsReadOnly": false,
"UiType": "",
"IsRequired": true
}
],
"ChildViews": [
]
}
the get GetEntityView will always create a new version in case of edit, so there would be any issue for the concurrency, the same request response can be used to update the entity with the latest values.
No comments:
Post a Comment