Product object

Prev Next

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.

your title goes here
If you pass any nil/null or empty string to this method, it will return an empty and invalid product object. Any product-related operations will ignore an invalid product object.

The following parameters are required for the product object:

ParameterData Type
productIDString
nameString
taxonomyArray (of string)
imageURLString
priceDouble
currencyString

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");
your title goes here
Make sure to set the attributes in the given data types, and set no attribute as nil/null or as an empty string. 

The following table lists the properties you can set with the product object.

PropertyDescriptionData TypeSample ValueRequired
productIDUnique product ID of the productString"sku1234"Yes
nameProduct nameString"Blue dress"Yes
taxonomyCategory tree of the product[String]["Dresses","Night Dresses","Long Sleeve"]Yes
pricePrice of the product without any discount(s)Double100Yes
salePriceUnit price of the productDouble95.2No
imageURLURL address of the product imageString"posh.useinsider.com/sku1234-img.png"Yes
currencyCurrency of the productString"USD"Yes
stockStock information of the productInt10No
colorColor of the product selected by the userString"Blue"No
voucherNameProduct voucher nameString"SUMMER2025"No
voucherDiscountVoucher discount of the productDouble10.5No
promotionNamePromotion name of the productString"Holiday Sale"No
promotionDiscountPromotion discount of the productDouble5No
groupcodeInformation for group product variantsString"abc123"No
sizeSize of the product selected by the userString"S"No
shippingCostShipping cost informationDouble10.5No
quantityQuantity of the productInt1No
InStockStock information of the productBoolTrueNo
setTagsTags 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. 

ParameterData Type
colorString

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. 

ParameterData Type
voucherNameString

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. 

ParameterData Type
voucherDiscountDouble

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. 

ParameterData Type
promotionNameString

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. 

ParameterData Type
promotionDiscountDouble

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. 

ParameterData Type
groupcodeString

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.

ParameterData Type
sizeString

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.

ParameterData Type
salePriceDouble

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. 

ParameterData Type
shippingCostDouble

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. 

ParameterData Type
quantityInteger

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. 

ParameterData Type
stockInteger

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.

ParameterData Type
InStockBoolean

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueString

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueInteger

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueBoolean

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueDouble

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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueDate 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.

your title goes here
Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores.
ParameterData Type
keyString
valueArray (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.

your title goes here
Your attribute key should be only numbers. Otherwise, this attribute will be ignored.
ParameterData Type
keyNumber
valueArray (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.