Skip to main content

Rules - Functions

Updated today

Koongo offers a range of functions for working with text and collections. These functions allow you to clean, format, and transform attribute values, ensuring your product data is structured, consistent, and ready for marketplace export.

Text functions

Enables you to apply various formatting and cleaning operations to text values.

Trim whitespace on start and end

Removes whitespace on start and end of the text value.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Flexfit mini ottoman cap

Define the following operations:

  • trim whitespace on start and end

As a result, you get the following:

  • Flexfit mini ottoman cap

Upper case only first character

Changes the first character to uppercase.

Example:

Use attribute as input to the Rule:

  • Title - attribute value flexfit mini ottoman cap

Define the following operations:

  • upper case only first character

As a result, you get the following:

  • Flexfit mini ottoman cap

Upper case first character of each word

Changes all first characters at each word to uppercase.

Example:

Use attribute as input to the Rule:

  • Title - attribute value flexfit mini ottoman cap

Define the following operations:

  • upper case first character of each word

As a result, you get the following:

  • Flexfit Mini Ottoman Cap

Upper case all characters

Changes all characters to uppercase.

Example:

Use attribute as input to the Rule:

  • Title - attribute value flexfit mini ottoman cap

Define the following operations:

  • upper case all characters

As a result, you get the following:

  • FLEXFIT MINI OTTOMAN CAP

Lower case all characters

Changes all characters to uppercase.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Flexfit Mini Ottoman Cap

Define the following operations:

  • lower case all characters

As a result, you get the following:

  • flexfit mini ottoman cap

Remove all non-numeric characters

Removes all non-numeric characters.

Example:

Use attribute as input to the Rule:

  • Title - attribute value ADIDAS | SUPERSTAR 80S live3

Define the following operations:

  • remove all non-numeric characters

As a result, you get the following:

  • 803

Remove all numeric characters

Removes all numeric characters.

Example:

Use attribute as input to the Rule:

  • Title - attribute value ADIDAS | SUPERSTAR 80S live3

Define the following operations:

  • remove all numeric characters

As a result, you get the following:

  • ADIDAS | SUPERSTAR S live

Remove all HTML tags/element

Removes all HTML characters from the text.

Example:

Use attribute as input to the Rule:

  • Title - attribute value <p>Flexfit <strong>Mini Ottoman</strong> Cap</p>

Define the following operations:

  • remove all HTML characters

As a result, you get the following:

  • Flexfit Mini Ottoman Cap

Remove all spaces

Removes all whitespaces.

Example:

Use attribute as input to the Rule:

  • Title - attribute value ADIDAS | SUPERSTAR 80S live3

Define the following operations:

  • remove all whitespace

As a result, you get the following:

  • ADIDAS|SUPERSTAR80Slive3

Remove all end-of-line characters

Removes all end-of-line characters & linebreaks from the text value.

Example:

Use attribute as input to the Rule:

  • Title - attribute value ADIDAS | SUPERSTAR 80S live3\n

Define the following operations:

  • remove all end-of-line characters

As a result, you get the following:

  • ADIDAS | SUPERSTAR 80S live3

Remove special characters

Removes special characters from the attribute value.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Flexfit mini ottoman cap~

Define the following operations:

  • remove special characters

As a result, you get the following:

  • Flexfit mini ottoman cap

Convert text to HTML

Converts plain text into HTML-safe text by replacing all characters with their HTML entities. This prevents broken formatting and ensures the value displays correctly in channels that expect HTML.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Tom & Jerry <Sale> "50%"

Define the following operations:

  • convert text to HTML

As a result, you get the following:

  • Tom &amp; Jerry &lt;Sale&gt; &quot;50%&quot;

Convert text to HTML - only: &, ", ', <, >

Converts plain text into HTML-safe text by replacing only special characters with their HTML entities. This option is useful when you want to convert only the most common HTML-sensitive characters while keeping the rest of the text unchanged.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Men's T-shirt <Limited Edition> & Accessories

Define the following operations:

  • convert text to HTML - only: &, ", ', <, >

As a result, you get the following:

  • Men&#39;s &quot;T-shirt&quot; &lt;Limited Edition&gt; &amp; Accessories


Convert HTML to text

Converts HTML into plain text by replacing all HTML entities. This prevents broken formatting and ensures the value displays correctly in channels that expect plain text.

Example:

Use attribute as input to the Rule:

  • Description - attribute value Tom &amp; Jerry &lt;Sale&gt; &quot;50%&quot;

Define the following operations:

  • convert HTML to text

As a result, you get the following:

  • Tom & Jerry <Sale> "50%"

Convert HTML to text - only: &amp;, &quot;, &#039;, &lt, &gt;

Converts HTML into plain text by replacing only the following special characters &amp;, &quot;, &#039;, &lt, &gt; with their corresponding text entities. This option is useful when you want to convert only specific HTML-sensitive characters while keeping the rest of the HTML unchanged.

Example:

Use attribute as input to the Rule:

  • Title - attribute value Men's T-shirt <Limited Edition> & Accessories

Define the following operations:

  • convert text to HTML - only: &, ", ', <, >

As a result, you get the following:

  • Men&#39;s &quot;T-shirt&quot; &lt;Limited Edition&gt; &amp; Accessories

Convert text to base64

Encodes plain text into Base64 format. Base64 is commonly used to safely transmit data in systems that only support text-based formats. This function is useful when text needs to be safely transferred, stored, or embedded in environments that require encoded data.

Example:

Use attribute as input to the Rule:

  • Description - attribute value Hello World

Define the following operations:

  • convert text to base64

As a result, you get the following:

  • SGVsbG8gV29ybGQ=

Convert base64 to text

Decodes a Base64-encoded value back into readable plain text. This function is useful when you need to convert encoded data back into its original text format for further processing or export.

Example:

Use attribute as input to the Rule:

  • Description - attribute value SGVsbG8gV29ybGQ=

Define the following operations:

  • convert base64 to text

As a result, you get the following:

  • Hello World

Collection functions

Collections are typically created when using the COMBINE option to merge multiple attribute values into a single list. This creates a collection indexed from 0 onward, containing all selected attribute values. Collections allow you to work with multiple values at once, such as sorting, filtering, or selecting specific items.

Example:

Suppose your store contains multiple size attributes, such as Size, Size_shirts, and Size_shoes. First, you combine these attributes into a collection. For a specific product, the collection might look like: ['', '36', ''], where '' represents an empty value. You can then apply collection function, such as First non-empty item, to automatically select the first available size value amongst all the Size attributes used & get the size '36' exported.

Koongo provides the following collection functions to help you manage and transform grouped attribute values:

Sort

The 'sort' operation allows you to sort a collection alphabetically that arises from text operations or by merging several attributes into a collection.

Example:

Combine multiple attributes as input to the Rule:

  • 'Category name' - attribute value Shoes

  • 'Title' - attribute value ADIDAS

Define the following operations:

  • sort(ascending)

  • take first element as string

As a result, you get the following:

  • ADIDAS

ME_Collections_1.png

Unique collection

Takes a collection of attribute values and returns a new collection containing only unique elements, eliminating all duplicates.

Example:

Combine multiple attributes as input to the Rule:

Use multiple attributes as input to the Rule:

  • 'Sku' - attribute value 44450

  • 'Article code' - attribute value 44450

  • 'EAN' - attribute value 8576987425412

Define the following operations:

  • unique collection

  • convert collection into text

As a result, you get the following:

  • 44450 8576987425412

Slice collection items

The 'slice collection items' operation allows you to select specific elements from a collection. If the length is not filled, Koongo selects all elements to the end. Take From is indexed from 0, so the first element in the field has a position of 0.

Example:

Combine multiple attributes as input to the Rule:

  • 'Category name' - attribute value Shoes

  • 'Title' - attribute value ADIDAS

  • 'Category id' - attribute value 1234

Define the following operations:

  • slice collection items

  • take from - 1 (You need to select an index from where the slice should start. The first position has index 1.)

  • length - 2

  • take first item as text

As a result, you get the following:

  • ADIDAS

ME-collection_2.png

Remove empty elements

The 'remove empty elements' allows you to delete empty values from a collection.

Example:

Combine multiple attributes as input to the Rule:

  • 'Category name' - empty value

  • 'Title' - attribute value ADIDAS

  • 'Category id' - attribute value 1234

Define the following operations:

  • remove empty elements

  • take first element as string

As a result, you get the following:

  • ADIDAS

ME_Collections_4.png

Take first item as text

The 'take first item as text' operation allows you to select the first element from a collection. The element is transferred to the 'string' format automatically. If you need a 'number' format, please use the 'cast as number' operation.

Example:

Use Tags attribute as input to the Rule:

  • 'Tags' - attribute value adidas, backpack, egnition-sample-data

Define the following operations:

  • split text to collection

  • split on - ','

  • Take first item as text

As a result, you get the following:

  • adidas

ME-collection_3.png

Take last item as text

The 'take last item as text' operation allows you to select just the last element from a collection. The element is transferred to the 'string' format automatically. If you need a 'number' format, please use the 'cast as number' operation.

Example:

Use Tags attribute as input to the Rule:

  • 'Tags' - attribute value adidas, backpack, egnition-sample-data

Define the following operations:

  • split text to collection

  • split on - ','

  • take last item as text

As a result, you get the following:

  • egnition-sample-data

ME-collection_4.png

Take first non-empty item as text

From a collection of attributes, select the first attribute value that is not empty, null, or blank and return it as a text/string value. This function is pretty useful to check a bunch of attributes and export the first one containing values.

Example:

Combine multiple attribute as input to the Rule:

  • 'Color' - attribute value white

  • 'Shopify - Color' - attribute value 'empty'

  • 'Farbe' - attribute value beige

Define the following operations:

  • take first non-empty item as text

As a result, you get the following:

  • white

Convert collection into text

The 'Convert collection into text' allows you to create a text from a collection separated by a selected separator. The separator can be a space.

Example:

Use Tags attribute as input to the Rule:

  • 'Tags' - attribute value adidas, backpack, egnition-sample-data

Define the following operations:

  • split text to collection

  • split on - ','

  • convert collection into text

  • join with - '-'

As a result, you get the following:

  • adidas/backpack/egnition-sample-data

ME-collection_5.png

Serialize collection to text (json)

The 'Serialize collection into text (json)' converts a collection of attribute values into a JSON-formatted string representation.

Example:

Use Tags attribute as input to the Rule:

  • 'Title (name)' - attribute value Shoe11

  • 'Color' - attribute value Black

  • 'Tags' - attribute value backora, dalsi, novy, postman

Define the following operations:

  • serialize collection to text (json)

As a result, you get the following:

  • ["Shoe11","Black","backora, dalsi, novy, postman"]

Export Gallery

Export gallery is a formatting operation that takes a collection of image URLs (or image objects) and outputs them as a single formatted block of text/HTML arranged into a gallery layout (grid/rows), with configurable spacing and styling.

Example:

Use multiple attributes as input to the Rule:

Define the following operations:

  • export gallery

As a result, you get the following:

  • <table cellspacing="1" cellpadding="4" style="border-collapse: separate;">
    <tr>
    <td style="border:1px solid #000;">
    <img src="https://cdn.shopify.com/s/files/1/0762/7039/files/SAWDU1-51_Laf240_1.jpg?v=1686163289" style="display:block;" />
    </td>
    <td style="border:1px solid #000;">
    <img src="https://cdn.shopify.com/s/files/1/0762/7039/files/SAWDU1-52_Laf240_1.jpg?v=1686163289" style="display:block;" />
    </td>
    </tr>
    <tr>
    <td style="border:1px solid #000;">
    <img src="https://cdn.shopify.com/s/files/1/0762/7039/files/SAWDU1-53_Laf240_2.jpg?v=1686163289" style="display:block;" />
    </td>
    <td style="border:1px solid #000;">
    <img src="https://cdn.shopify.com/s/files/1/0762/7039/files/SAWDU1-54_Laf240_2.jpg?v=1686163289" style="display:block;" />
    </td>
    </tr>
    </table>

Format to media gallery

The 'first non-empty item' operation allows you to select the first non-empty value. You can use it, for example, to search through several attributes - Return the first non-empty value.

Example:

Use multiple attributes as input to the Rule:

Define the following operations:

  • Format to media gallery

As a result, you get the following:

Proxy images via koongo

Koongo will rewrite your product image URLs so the marketplace/channel downloads the images through Koongo’s image proxy instead of requesting them directly from your shop/CDN.

Example:

Use multiple attributes as input to the Rule:

Define the following operations:

  • proxy images via koongo

  • take first image url

As a result, you get the following:

Take first image url

Selects the first available image URL from a collection of links and returns it as the output value.

Example:

Use multiple attributes as input to the Rule:

Define the following operations:

  • takes first image Url

As a result, you get the following:

Convert images url into text (join)

Takes multiple image URLs from a collection and combines them into a single text string using a specified separator (delimiter).

Example:

Use multiple attributes as input to the Rule:

Define the following operations:

  • convert images url into text (join)

As a result, you get the following:

Did this answer your question?