Product object is required for revenue tracking, recommendation engine, and campaigns such as cart reminder. This article explains how you can set the product object and product attributes.
Set product object
Once you create a product object, you can set its attributes. You can set predefined (e.g., color, size, voucher name, sub-category, etc.) and custom attributes.
The following parameters are required for the product object:
| Parameter | Data Type |
|---|---|
| productID | String |
| name | String |
| taxonomy | Array (of string) |
| imageURL | String |
| price | Double |
| currency | String |
Method Signature
+(InsiderProduct *)createNewProductWithID:(NSString *)productID name:(NSString *)name taxonomy:(NSArray *)taxonomy imageURL:(NSString *)imageURL price:(double)price currency:(NSString *)currency;Method Examples
NSArray *taxonomy = [NSArray arrayWithObjects: @"taxonomy1", @"taxonomy2", @"taxonomy3", nil];
InsiderProduct *insiderExampleProduct = [Insider createNewProductWithID:@"productID" name:@"productName" taxonomy:taxonomy imageURL:@"imageURL" price:1000.5 currency:@"currency"];let taxonomy = ["taxonomy1", "taxonomy2", "taxonomy3"]
let insiderExampleProduct = Insider.createNewProduct(withID: "productID", name: "productName", taxonomy: taxonomy, imageURL: "imageUrl", price: 1000.5, currency: "currency")Set color attribute
This method allows you to set the color attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| color | String |
Method Signature
-(InsiderProduct*(^)(NSString *))setColor;Method Examples
insiderExampleProduct.setColor(@"color");insiderExampleProduct?.setColor()("color")Set voucher name attribute
This method allows you to set the voucher name attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| voucherName | String |
Method Signature
-(InsiderProduct*(^)(NSString *))setVoucherName;Method Examples
insiderExampleProduct.setVoucherName(@"voucherName");insiderExampleProduct?.setVoucherName()("voucherName")Set voucher discount attribute
This method allows you to set the voucher discount attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| voucherDiscount | Double |
Method Signature
-(InsiderProduct*(^)(double))setVoucherDiscount;Method Examples
insiderExampleProduct.setVoucherDiscount(10.5);insiderExampleProduct?.setVoucherDiscount()(10.5)Set promotion name attribute
This method allows you to set the promotion name attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| promotionName | String |
Method Signature
-(InsiderProduct*(^)(NSString *))setPromotionName;Method Examples
insiderExampleProduct.setPromotionName(@"promotionName");insiderExampleProduct?.setPromotionName()("promotionName")Set promotion discount attribute
This method allows you to set the promotion discount attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| promotionDiscount | Double |
Method Signature
-(InsiderProduct*(^)(double))setPromotionDiscount;Method Examples
insiderExampleProduct.setPromotionDiscount(10.5);insiderExampleProduct?.setPromotionDiscount()(10.5)Set GroupCode attribute
This method allows you to set the groupcode of your Insider product object.
| Parameter | Data Type |
|---|---|
| groupcode | String |
Method Signature
-(InsiderProduct*(^)(NSString *))setGroupCode;Method Example
insiderExampleProduct.setGroupCode(@"groupCode");insiderExampleProduct?.setGroupCode()("groupCode")Set Size attribute
This method allows you to set the size attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| size | String |
Method Signature
-(InsiderProduct*(^)(NSString *))setSize;Method Examples
insiderExampleProduct.setSize(@"size");insiderExampleProduct?.setSize()("size")Set sale price attribute
This method allows you to set the sale price attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| salePrice | Double |
Method Signature
-(InsiderProduct*(^)(double))setSalePrice;Method Examples
insiderExampleProduct.setSalePrice(10.5);insiderExampleProduct?.setSalePrice()(10.5)Set shipping cost attribute
This method allows you to set the shipping cost attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| shippingCost | Double |
Method Signature
-(InsiderProduct*(^)(double))setShippingCost;Method Examples
insiderExampleProduct.setShippingCost(10.5);insiderExampleProduct?.setShippingCost()(10.5)Set quantity attribute
This method allows you to set the quantity attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| quantity | Integer |
Method Signature
-(InsiderProduct*(^)(int))setQuantity;Method Examples
insiderExampleProduct.setQuantity(10);insiderExampleProduct?.setQuantity()(10)Set stock attribute
This method allows you to set the stock attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| stock | Integer |
Method Signature
-(InsiderProduct*(^)(int))setStock;Method Examples
insiderExampleProduct.setStock(10);insiderExampleProduct?.setStock()(10)Set InStock attribute
This method allows you to set the InStock attribute for your Insider product object.
Method Signature
-(InsiderProduct *(^)(BOOL))setInStockMethod Example
insiderExampleProduct.setInStock(true);insiderExampleProduct?.setInStock()(true)Set brand attribute
This method allows you to set the brand of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setBrand;Method Examples
insiderExampleProduct.setBrand(@"brand");insiderExampleProduct?.setBrand()("brand")
Set stock keeping unit attribute
This method allows you to set the stock keeping unit of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setSku;Method Examples
insiderExampleProduct.setSku(@"sku");insiderExampleProduct?.setSku()("sku")Set gender attribute
This method allows you to set the gender of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setGender;Method Examples
insiderExampleProduct.setGender(@"gender");insiderExampleProduct?.setGender()("gender")Set multipack attribute
This method allows you to set the multipack of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setMultipack;Method Examples
insiderExampleProduct.setMultipack(@"multipack");insiderExampleProduct?.setMultipack()("multipack")Set product type attribute
This method allows you to set the product type of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setProductType;Method Examples
insiderExampleProduct.setProductType(@"productType");insiderExampleProduct?.setProductType()("productType")Set global trade item number attribute
This method allows you to set the global trade item number of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setGtin;Method Examples
insiderExampleProduct.setGtin(@"gtin");insiderExampleProduct?.setGtin()("gtin")Set description attribute
This method allows you to set the description of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSString *))setDescription;Method Examples
insiderExampleProduct.setDescription(@"description");insiderExampleProduct?.setDescription()("description")Set tags attribute
This method allows you to set the tags of your Insider product object.
Method Signature
-(InsiderProduct*(^)(NSArray<NSString *> *))setTags;Method Examples
insiderExampleProduct.setTags(@[@"tag1", @"tag2"]);insiderExampleProduct?.setTags()(["tag1", "tag2"])Set custom string attribute
This method allows you to set the custom string attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | String |
Method Signature
-(InsiderProduct*(^)(NSString *, NSString *))setCustomAttributeWithString;Method Examples
insiderExampleProduct.setCustomAttributeWithString(@"key", @"value");insiderExampleProduct?.setCustomAttributeWithString()("key", "value")Set custom integer attribute
This method allows you to set the custom integer attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Integer |
Method Signature
-(InsiderProduct*(^)(NSString *, int))setCustomAttributeWithInt;Method Examples
insiderExampleProduct.setCustomAttributeWithInt(@"key", 10);insiderExampleProduct?.setCustomAttributeWithInt()("key", 10)Set custom boolean attribute
This method allows you to set the custom boolean attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Boolean |
Method Signature
-(InsiderProduct *(^)(NSString *, bool))setCustomAttributeWithBoolean;Method Examples
insiderExampleProduct.setCustomAttributeWithBoolean(@"key", true);insiderExampleProduct?.setCustomAttributeWithBoolean()("key", true)Set custom double attribute
This method allows you to set the custom double attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Double |
Method Signature
-(InsiderProduct*(^)(NSString *, double))setCustomAttributeWithDouble;Method Examples
insiderExampleProduct.setCustomAttributeWithDouble(@"key", 10.5);insiderExampleProduct?.setCustomAttributeWithDouble()("key", 10.5)Set custom date attribute
This method allows you to set the custom date attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Date object |
Method Signature
-(InsiderProduct*(^)(NSString *, NSDate *))setCustomAttributeWithDate;Method Examples
NSDate *date = [NSDate date];
insiderExampleProduct.setCustomAttributeWithDate(@"key", date);let date = Date()
insiderExampleProduct?.setCustomAttributeWithDate()("key", date)Set custom array of string attribute
This method allows you to set the custom array of string attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Array (of string) |
Method Signature
- (InsiderProduct*(^)(NSString *, NSArray<NSString *> *))setCustomAttributeWithStringArray;Method Examples
InsiderProduct *insiderExampleProduct = [Insider createNewProductWithID:@"product_id"
name:@"product_name"
taxonomy:@[@"taxonomy_1", @"taxonomy_2"]
imageURL:@"https://useinsider.com/image_url"
price:123.45
currency:@"USD"];
NSArray<NSString *> *stringArray = @[@"value1", @"value2", @"value3"];
[insiderExampleProduct setCustomAttributeWithStringArray](@"key", stringArray);let insiderExampleProduct = Insider.createNewProduct(
withID: "product_id",
name: "product_name",
taxonomy: ["taxonomy_1", "taxonomy_2"],
imageURL: "https://useinsider.com/image_url",
price: 123.45,
currency: "USD"
)
let stringArray = ["value1", "value2", "value2"]
insiderExampleProduct?.setCustomAttributeWithStringArray()("key", stringArray)Set custom array of number attribute
This method allows you to set the custom array of number attribute for your Insider product object.
| Parameter | Data Type |
|---|---|
| key | Number |
| value | Array (of number) |
Method Signature
- (InsiderProduct*(^)(NSString *, NSArray<NSNumber *> *))setCustomAttributeWithNumericArray;Method Examples
InsiderProduct *insiderExampleProduct = [Insider createNewProductWithID:@"product_id"
name:@"product_name"
taxonomy:@[@"taxonomy_1", @"taxonomy_2"]
imageURL:@"https://useinsider.com/image_url"
price:123.45
currency:@"USD"];
[insiderExampleProduct setCustomAttributeWithNumericArray](@"key", @[@5, @3.14, @100]);let insiderExampleProduct = Insider.createNewProduct(
withID: "product_id",
name: "product_name",
taxonomy: ["taxonomy_1", "taxonomy_2"],
imageURL: "https://useinsider.com/image_url",
price: 123.45,
currency: "USD"
)
insiderExampleProduct?.setCustomAttributeWithNumericArray()("key", [5, 3.14, 10])