Product attribute: Assign number or text
    • PDF

    Product attribute: Assign number or text

    • PDF

    Article summary

    In this article, you will learn how to assign a value to product attributes, for example a number, a calculation result or a text.

    This allows you to assign individual properties to individual recommendation units in your product file.

    These types of actions are listed in the user interface of the rules under Select an action > Product attribute action.


    Activate product attributes for the rules

    Before you can access columns of your product data in the rules, you must first make them available for the rules.

    1. Open the Data Sources section in the workbench.

    2. Click on the file stored there.

    3. Copy the following code template under Data Schema:

      {
          "type": "object",
          "properties": {
              "ATTRIBUTE-NAME-1": {
                  "type": "string"
              },
              "ATTRIBUTE-NAME-2": {
                  "type": "string"
              },
              "ATTRIBUTE-NAME-3": {
                  "type": "string"
              },
              "ATTRIBUTE-NAME-4": {
                  "type": "string"
              }
          },
          "required": ["ATTRIBUTE-NAME-1", "ATTRIBUTE-NAME-2", "ATTRIBUTE-NAME-3", "ATTRIBUTE-NAME-4"]
      }
    4. Change the elements ATTRIBUTE-NAME-1 - 4 to the names of the attributes from your product file that you want to use in the rules.

    💡The template contains space for four attributes. If you need more, add the section to the code:

            "ATTRIBUTE-NAME-1": {

                "type": "string"

            },

    Also remember to list each attribute under "required". If you need fewer attributes, remove the relevant sections.


    Assign numbers and calculation results to a product attribute

    Action: Set product attribute to a number / calculated value

    With this action, the platform assigns a specific numerical value or the result of a calculation to a product attribute from your data.

    In this way, you can define an individual number for each product recommendation, such as the number required by the user.

    1. Selection of the action

    1. Click on Select an action > Set product attribute to a number / calculated value.

    💡 In the next step, you define whether you want to assign the value to all or only certain products.

    2.1 Assign a number / calculation result to all products

    The number or calculation result is assigned to all products from the imported product file without exception.

    Click on the dropdown above and select the option for all products.

    2.2 Assign number / calculation result to user-defined products

    The number or calculation result is only assigned to certain products from the imported product file. With this option, you define an additional condition under which the platform assigns a figure or a calculation result to a product.

    1. Click on the top dropdown and select the option for some products depending on a condition.

    1. Click on Select a product condition.
      This defines the condition under which the value is assigned to a product.

    💡 You have the choice between two options:

    • If a product attribute is > / < / = /… a number: Compares an attribute with a number/calculation result. You cannot use texts here.

    • If a product attribute is equal to / contains /… a text: Compares an attribute with a text. With this option, a combination of texts and numbers/calculation results is possible.

    1. Under Product condition > Product attribute name, select the product attribute that you want to use for the condition.

    2. Select the operator under equals.

    3. Enter the numerical or text value with which the attribute is compared in the gray field.

    3. Assign a value to a product attribute

    1. Under set product attribute, select the product attribute that you want to overwrite with the value.

    2. Enter the numerical or text value with which the attribute is compared in the gray field.

      1. To use input from user answers, click on Answer value.

      2. To use product attributes, click on Product attribute value.

      3. To use variables, click on Variable value.

    Example: Assign text + calculation result to specific products

    Scenario: You want to sell wall colors to your customers. A text should appear on the result page , particularly for the colors, informing the customer about the required number of paint buckets . The number stems from a calculation in which the wall area entered by the user is included. The question about the wall area is optional, i.e. the user can skip it.

    Configure condition for the action

    1. Set the rule trigger to depending on a condition.

    2. Click on Select a condition > If a particular question is selected.

    3. Under Select a condition, choose the question refering to the wall surface.

      1. This configures the condition: To activate the rule, the selector user must answer the question about the wall area. If the user skips the question, no text appears next to the colors.

    1. For if yes choose Select an action > Set product attribute to text.

      1. if yes defines the case in which the condition applies (i.e. the user answers the question about the wall area in the questionnaire).

    Configure condition for the text field

    1. Within the action, select the option for some products depending on a condition.

      1. The text should not appear for all products, but only for the colors.

    2. Click on Select a product condition > If a product attribute is > / < / = /… a number.

      1. In this example, the product data contains a column that identifies each color with a 1. This is why you compare the product attribute with a number.

    3. Configure the product condition: Under Product attribute, select the column from the product data (SortColor), set the operator to equals and enter a 1 in the gray field.

      1. This means that the platform only executes the action for the products that contain a 1 in the SortColor column in the product data.

    Configure text with calculation: Recommendation of the number of paint buckets

    8. Under Product attribute name, select the attribute from the product data that should contain the text. In the example, we use the column storage.

    9. Enter the text and the calculation. To start the calculation, use the math() function.

    a. To include the wall area in the calculation, click on Answer value and select the answer (shown in the image as the blue tile Fläche (= area)).

    b. To include the size of the paint buckets in the calculation, click on Product attribute value and select the attribute (shown in the image as the green tile size).

    Display text with calculation on result page

    1. Save your work status and switch to the Result Page workbench area.

    2. Under the tab Product Sections, select the section Additional data.

    3. Under DataSource Column, select the storage attribute.

      1. This displays the storage attribute on the result page, which receives the text and calculation via the rule.

    The configuration is complete. You can leave the if no section within the rule empty, because: If the condition does not apply (i.e. the user does not answer the question about the wall area = if no), then nothing should happen. This means that no text appears.


    Was this article helpful?