Combine attributes from different columns to create dynamic values

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

You can create dynamic product information by using input from other columns. Input from other columns is useful if you want to, for example, create optimized titles where you wish to add a product's brand and color in the title to symbolize product variants.

Append or prepend the data from another column

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

  1. Go to Data View and select Intermediate to choose the stage where you wish to add a box.

    • You can also select Intermediate or the export stage in Dataflow by selecting the small arrow that appears when you hover over an attribute in either 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 box.

  4. Select the column you want to append or prepend and chose either append or prepend for the value.

  5. Optionally, you can choose to add static text before or after the column value and select Save.

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, consider using the Text Template box. The Text Template box functions similarly to the Append/Prepend Column box but gives you the option to 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 then receive a dynamic output consisting of your static placeholder text and the dynamic values for each item.

Note

If you don't write the attribute name correctly, the Text Template 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 box. The Text Template box lets you directly write code using Twig to define your functions.

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

  1. Add the Text Template 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: 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 box.

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

  2. Select the column you want to append or prepend and chose either append or prepend for the value.

  3. Optionally, you can choose to add static text before or after the column value and select Save.

Append or prepend a column to a specified character limit

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

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

  2. Select the column you want to append or prepend and chose either append or prepend for the value.

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

  4. Optionally, you can choose to add static text before or after the column value and select Save.