The method signatures provided in this guide can also be applied to Kotlin.
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.
The Java method signatures and examples in this guide apply to Kotlin as well.
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
public InsiderProduct createNewProduct(String id, String name, String[] taxonomy, String imageURL, double price, String currency)Method Example
String[] taxonomy = {"taxonomy1", "taxonomy2", "taxonomy3"};
InsiderProduct insiderExampleProduct = Insider.Instance.createNewProduct("productID", "productName", taxonomy, "imageURL", 1000.5, "currency");The following table lists the properties you can set with the product object.
| Property | Description | Data Type | Sample Value | Required |
|---|---|---|---|---|
| productID | Unique product ID of the product | String | "sku1234" | Yes |
| name | Product name | String | "Blue dress" | Yes |
| taxonomy | Category tree of the product | [String] | ["Dresses","Night Dresses","Long Sleeve"] | Yes |
| price | Price of the product without any discount(s) | Double | 100 | Yes |
| salePrice | Unit price of the product | Double | 95.2 | No |
| imageURL | URL address of the product image | String | "posh.useinsider.com/sku1234-img.png" | Yes |
| currency | Currency of the product | String | "USD" | Yes |
| stock | Stock information of the product | Int | 10 | No |
| color | Color of the product selected by the user | String | "Blue" | No |
| voucherName | Product voucher name | String | "SUMMER2025" | No |
| voucherDiscount | Voucher discount of the product | Double | 10.5 | No |
| promotionName | Promotion name of the product | String | "Holiday Sale" | No |
| promotionDiscount | Promotion discount of the product | Double | 5 | No |
| groupcode | Information for group product variants | String | "abc123" | No |
| size | Size of the product selected by the user | String | "S" | No |
| shippingCost | Shipping cost information | Double | 10.5 | No |
| quantity | Quantity of the product | Int | 1 | No |
| InStock | Stock information of the product | Bool | True | No |
| setTags | Tags information of the product | [String] | ["tag1","tag2"] | No |
Set color attribute
This method allows you to set the color attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| color | String |
Method Signature
public InsiderProduct setColor(String color)Method Example
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
public InsiderProduct setVoucherName(String voucherName)Method Example
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
public InsiderProduct setVoucherDiscount(double voucherDiscount)Method Example
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
public InsiderProduct setPromotionName(String promotionName)Method Example
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
public InsiderProduct setPromotionDiscount(double promotionDiscount)Method Example
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
public InsiderProduct setGroupCode(String groupCode)Method Example
insiderExampleProduct.setGroupCode("XXYYZZ");Set size attribute
This method allows you to set the size attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| size | String |
Method Signature
public InsiderProduct setSize(String size)Method Example
insiderExampleProduct.setSize("size");Set sale price attribute
This method allows you to set the sale price attribute of your Insider product object.
If the salePrice attribute is provided, the calculations will be made based on this attribute. If not, the calculations will continue to use the price attribute, which remains to be a required field in the mobile app SDK.
| Parameter | Data Type |
|---|---|
| salePrice | Double |
Method Signature
public InsiderProduct setSalePrice(double salePrice)Method Example
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
public InsiderProduct setShippingCost(double shippingCost)Method Example
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
public InsiderProduct setQuantity(int quantity)Method Example
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
public InsiderProduct setStock(int stock)Method Example
insiderExampleProduct.setStock(10);Set InStock attribute
This method allows you to set the InStock attribute of your Insider product object.
| Parameter | Data Type |
|---|---|
| InStock | Boolean |
Method Signature
public InsiderProduct setInStock(boolean stock)Method Example
insiderExampleProduct.setInStock(true);Set brand attribute
This method allows you to set the brand of your Insider product object.
Method Signature
public InsiderProduct setBrand(String brand)Method Example
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
public InsiderProduct setSku(String sku)Method Example
insiderExampleProduct.setSku("sku");Set gender attribute
This method allows you to set the gender of your Insider product object.
Method Signature
public InsiderProduct setGender(String gender)Method Example
insiderExampleProduct.setGender("gender");Set multipack attribute
This method allows you to set the multipack of your Insider product object.
Method Signature
public InsiderProduct setMultipack(String multipack)Method Example
insiderExampleProduct. setMultipack("multipack"");Set product type attribute
This method allows you to set the product type of your Insider product object.
Method Signature
public InsiderProduct setProductType(String productType)Method Example
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
public InsiderProduct setGtin(String gtin)Method Example
insiderExampleProduct.setGtin("gtin");Set description attribute
This method allows you to set the description of your Insider product object.
Method Signature
public InsiderProduct setDescription(String description)Method Example
insiderExampleProduct.setDescription("description");Set tags attribute
This method allows you to set the tags of your Insider product object.
Method Signature
public InsiderProduct setTags(String[] tags)Method Example
String[] tags = {"tag1", "tag2", "tag3"};
insiderExampleProduct.setTags(tags);
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
public InsiderProduct setCustomAttributeWithString(String key, String value)Method Example
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
public InsiderProduct setCustomAttributeWithInt(String key, int value)Method Example
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
public InsiderProduct setCustomAttributeWithBoolean(String key, boolean value)Method Example
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
public InsiderProduct setCustomAttributeWithDouble(String key, double value)Method Example
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
public InsiderProduct setCustomAttributeWithDate(String key, Date value)Method Example
Date date = new 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 setCustomAttributeWithStringArray(String key, String[] values)Method Example
String[] stringArray = new String[]{"value1", "value2", "value3"};
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 setCustomAttributeWithNumericArray(String key, Number[] values)Method Example
Number[] numberArray = new Number[]{5, 3.14, 100};
insiderExampleProduct.setCustomAttributeWithNumericArray("key", numberArray);Refer to I'm having issues with the product object for troubleshooting.