Changing the Default Product Structure in Swift SDK
The following is what the default product structure looks like according to the Dynamic Yield product feed structure:
public class DefaultRecsProductData: RecsProductData {
let productType: ProductType?
let groupId: String?
let name: String?
let url: String?
let price: Float?
let inStock: Bool?
let imageUrl: String?
let categories: [String?]?
var keywords: [String?]?
}
Changing the default using Swift SDK
To add more fields to the product structure:
- Create a new class that inherits from
RecsProductData
.
public class CustomRecsProductData: RecsProductData {
var shortColor: String = "yellow"
var tShirtNumber: Int = 8
var initials: String = "A.N"
}
- Set this class as the new default product data structure by calling
setDefaultProductDataType()
.
DYSdk.shared().setDefaultProductDataType(defaultRecsProductData: CustomRecsProductData.self)
- After calling
setDefaultProductDataType(
), wheneverchooseVariations
is called for recommendation campaigns, the return value includes the fields you added to the new class.
Updated 6 days ago
Did this page help you?