Skip to main content

Combine attributes from different columns to create dynamic values

Combine attributes from different columns to create dynamic values in Productsup.

Introduction

You can create dynamic product information by using values from other columns. For example, you can create optimized titles containing a product's brand and color to show product variants.

Append or prepend the data from another column

Use the Append/Prepend Column rule box to add data to the end or at the beginning of your current input column from another column. The Append/Prepend Column rule box automatically adds whitespace before the data you append or prepend.

  1. Go to Data View and select Intermediate stage or a certain export where you wish to add a box.

    • You can also select Intermediate or an export in Dataflow by selecting the small arrow that appears when you hover over an attribute in a column.

      Select the small arrow that appears when you hover over an attribute in either column.
  2. Select Edit for the column where you want to add a box. You can now see an open tab on the right-hand side.

  3. Select the Add Box drop-down menu to search for the Append/Prepend Column rule box.

  4. Select the column and choose either append or prepend in Mode.

  5. Optionally, you can add a static text before or after the column value.

  6. Select Save.

For example, the following setup appends the string EUR to the price column after a value:

append_column.png

Here is the output:

Current data 10.00 EUR

Create templates for text using data from other columns

If you want to link several attributes together, use the Text Template rule box. The Text Template rule box functions similarly to the Append/Prepend Column rule box but lets you link several columns together using static placeholder text.

To dynamically add the value of a column, enter the exact name of the column between a set of two curly brackets and whitespace. See the following example for the brand column:

{{ brand }}

If the column name contains whitespace or a special character, use the following format:

{{ fromField('product_type')|raw }}

This format extracts and adds the value from the product_type column.

  1. Add the Text Template box.

  2. Create a template using information from other columns and or static placeholder text.

    template.png

For each item, the text template retrieves the ID and brand for each product and inserts them into the text template. You receive a dynamic output consisting of your static placeholder text and the dynamic values for each item.

Note

If you write the attribute name incorrectly, the Text Template rule box adds nothing to the text.

Between the import and intermediate stages, you can only add an attribute from the import.

Between the intermediate and export stages, you can only add an attribute from the intermediate.

Use Twig to dynamically create new information

You can also input Twig directly into the Text Template rule box. The Text Template rule box lets you directly write code using Twig to define your functions.

In general, some rule boxes can perform the functions you need.

  1. Add the Text Template rule box.

  2. Define your Twig template. See the following Twig examples to create custom functions:

    1. Example

      Input: This is our upper price class watch model

      Goal: Replace upper price class with high value.

      Twig:

      {{ currentValue |replace({'upper price class':'high value'}) }}

      Output: This is our high-value watch model

      Alternative box: Use the Text Replace box to search for upper price class and replace it with high value.

    2. Example

      Input: N/A - the value is empty

      Goal: Change the current value to brand new if it is empty.

      Twig:

      {% if currentValue == '' %}{{'brand new'}}{% else %}{{currentValue}}{% endif %}

      Output if value is empty: brand new

      Alternative box: Set Value if Empty

    3. Example

      Current input: Laced Jacket

      Goal: Prepend the text cheap if the price is 129.79.

      Twig:

      {% if price == 129.79 %}{{'cheap #{currentValue'}}}{% else %}{{currentValue}}{% endif %}

      Output if price is 129.79: Cheap Laced Jacket

      Alternative box: The Set Value if Contains box searches the price column. It checks if it is equal to 129.79 before prepending the value cheap.

    4. Example

      Goal: If the delivery time is more than five days, the output should not come before the defined date, which is in five days. If the delivery time is less than five days, the output should read Within the next five days.

      Twig:

      {% if currentValue > 5 %}{{ "Not before #{"+5 days "|date("d.m.Y")}" }}{% else %}{{'Within the next 5 days'}}{% endif %}

Append or prepend the data from another column if it is not present

You can append or prepend another column if the value from the column is not already present. To perform this, use the Append/Prepend Column if Value Not Present rule box.

  1. Add the Append/Prepend Column if Value Not Present rule box.

  2. Select the column and choose either append or prepend in Mode.

  3. Optionally, you can add a static text before or after the column value.

  4. Select Save.

Append or prepend a column to a specified character limit

With the Add Column if Fits rule box, you can specify the max length of your product attribute. It lets you only append or prepend a column if it fits your specified length.

  1. Add the Add Column if Fits rule box and select the column you wish to append or prepend.

  2. Select the column and choose either append or prepend in Mode.

  3. In Max Length, specify a max character count.

  4. Optionally, you can add a static text before or after the column value.

  5. Select Save.