Customized Commerce + ODP
Integrate Customized Commerce with Optimizely Data Platform (ODP) in Commerce 14.13.0.
Note
These instructions are for the custom integration option, which only works with Optimizely Customized Commerce 14.
To integrate Optimizely Customized Commerce 13 with Optimizely Data Platform (ODP), see the instructions for the built-in application in ODP. You can only use one of the two integration options.
Commerce version 14.13.0 contains a new scheduled job called Export data to ODP to integrate Optimizely Customized Commerce with Optimizely Data Platform (ODP). This jobs transfers Customized Commerce data (including orders, customers, and products) to the configured ODP account.
See Import data from Optimizely Customized Commerce for more information on the integration.
ODPJobOptions
This contains settings for the ODP integration job.
Name | Description | Default |
---|---|---|
ExportCatalog | Export products and variants to ODP | true |
ExportCustomers | Export customers to ODP | true |
ExportOrders | Export orders to ODP | true |
IncludeProducts | Export products to ODP | true |
ProductBatchSize | Batch size when sending products to ODP | 50 |
OrderBatchSize | Batch size when sending orders to ODP | 50 |
CustomerBatchSize | Batch size when sending customers to ODP | 50 |
MarketKeys | Collection of MarketKey. These hold api url and access key to make api calls to ODP |
Configure through code
Use the following code sample to configure the integration through code.
services.Configure<ODPJobOptions>(o =>
{
o.MarketKeys = new List<MarketKey>
{
new ()
{
MarketId = "US",
AccessKey = "key",
EndpointUrl = "<https://api.zaius.com/>"
}
};
});
Configure through the configuration file
Use the following code sample to configure the integration through the configuration file.
{
"EPiServer" : {
"Commerce" : {
"ODPJob": {
"MarketKeys": [
{
"MarketId": "US",
"AccessKey": "key",
"EndpointUrl": "https://api.zaius.com/"
}
]
}
}
}
}
Custom fields for Customers
To create and populate custom fields into the ODP customers object, create an implementation of ICustomerCustomFieldsHandler
[ServiceConfiguration(ServiceType = typeof(ICustomerCustomFieldsHandler))]
public class CustomCustomers : ICustomerCustomFieldsHandler
{
public IEnumerable<SchemaObjectCreateField> CreateFields()
{
return new[]
{
new SchemaObjectCreateField
{
Name = "mark_customers_teststring",
DisplayName = "Mark ODP Connector string",
PublicRead = true,
Type = "string"
},
new SchemaObjectCreateField
{
Name = "mark_customers_testtimestamp",
DisplayName = "Mark ODP Connector timestamp",
PublicRead = true,
Type = "timestamp"
},
new SchemaObjectCreateField
{
Name = "mark_customers_testinteger",
DisplayName = "Mark ODP Connector integer",
PublicRead = true,
Type = "number"
},
new SchemaObjectCreateField
{
Name = "mark_customers_testdecimal",
DisplayName = "Mark ODP Connector decimal",
PublicRead = false,
Type = "number"
},
new SchemaObjectCreateField
{
Name = "mark_customers_testboolean",
DisplayName = "Mark ODP Connector boolean",
PublicRead = false,
Type = "boolean"
}
};
}
public Dictionary<string, object> GetFieldValues(ContactEntity contact)
{
var values = new Dictionary<string, object>();
var testString = contact.Properties.GetValue<string>("mark_customers_teststring", null);
if (!string.IsNullOrEmpty(testString))
{
values.Add("mark_customers_teststring", testString);
}
var testTimestamp = contact.Properties.GetValue<DateTime?>("mark_customers_testtimestamp", null);
if (testTimestamp != null)
{
values.Add("mark_customers_testtimestamp", testTimestamp.Value.ToString("s"));
}
var testInteger = contact.Properties.GetValue<int?>("mark_customers_testinteger", null);
if (testInteger != null)
{
values.Add("mark_customers_testinteger", testInteger.Value);
}
var testDecimal= contact.Properties.GetValue<decimal?>("mark_customers_testdecimal", null);
if (testDecimal != null)
{
values.Add("mark_customers_testdecimal", testDecimal.Value);
}
var testBoolean= contact.Properties.GetValue("mark_customers_testboolean", false);
values.Add("mark_customers_testboolean", testBoolean);
return values;
}
}
Custom fields for Products
To create and populate custom fields into the ODP products object. create an implementation of IProductCustomFieldsHandler
[ServiceConfiguration(ServiceType = typeof(IProductCustomFieldsHandler))]
public class CustomProducts : IProductCustomFieldsHandler
{
public IEnumerable<SchemaObjectCreateField> CreateFields()
{
return new[]
{
new SchemaObjectCreateField
{
Name = "mark_product_teststring",
DisplayName = "Mark ODP Connector string",
PublicRead = true,
Type = "string"
},
new SchemaObjectCreateField
{
Name = "mark_product_testtimestamp",
DisplayName = "Mark ODP Connector timestamp",
PublicRead = true,
Type = "timestamp"
},
new SchemaObjectCreateField
{
Name = "mark_product_testinteger",
DisplayName = "Mark ODP Connector integer",
PublicRead = true,
Type = "number"
},
new SchemaObjectCreateField
{
Name = "mark_product_testdecimal",
DisplayName = "Mark ODP Connector decimal",
PublicRead = false,
Type = "number"
},
new SchemaObjectCreateField
{
Name = "mark_product_testboolean",
DisplayName = "Mark ODP Connector boolean",
PublicRead = false,
Type = "boolean"
}
};
}
public Dictionary<string, object> GetFieldValues(EntryContentBase entry)
{
var values = new Dictionary<string, object>();
var testString = entry.GetValue("mark_product_teststring")?.ToString();
if (!string.IsNullOrEmpty(testString))
{
values.Add("mark_product_teststring", testString);
}
var testTimestamp = entry.GetValue("mark_product_testtimestamp") as DateTime?;
if (testTimestamp != null)
{
values.Add("mark_product_testtimestamp", testTimestamp.Value.ToString("s"));
}
var testInteger = entry.GetValue("mark_product_testinteger") as int?;
if (testInteger != null)
{
values.Add("mark_product_testinteger", testInteger.Value);
}
var testDecimal = entry.GetValue("mark_product_testdecimal") as decimal?;
if (testDecimal != null)
{
values.Add("mark_product_testdecimal", testDecimal.Value);
}
var testBoolean = entry.GetValue("mark_product_testboolean") as bool?;
if (testBoolean != null)
{
values.Add("mark_product_testboolean", testBoolean);
}
return values;
}
}
Updated 1 day ago