- PDF
Product attribute: Assign number or text
- PDF
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.
💡Check out the related article to learn more about the principle of conditions and actions.
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.
Open the Data Sources section in the workbench.
Click on the file.
Copy the following code template under Data Schema:
{ "type": "object", "properties": { "ATTRIBUTE-NAME-1": { "type": "string" } }, "required": ["ATTRIBUTE-NAME-1"] }
Change the element ATTRIBUTE-NAME-1 to the name of the attribute from your product file that you want to use in the rules.
💡The template contains space for one attribute. 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. Check the following examples.
✏️Example code with two attributes
{
"type": "object",
"properties": {
"ATTRIBUTE-NAME-1": {
"type": "string"
},
"ATTRIBUTE-NAME-2": {
"type": "string"
}
},
"required": ["ATTRIBUTE-NAME-1", "ATTRIBUTE-NAME-2"]
}
✏️Example code with three attributes
{
"type": "object",
"properties": {
"ATTRIBUTE-NAME-1": {
"type": "string"
},
"ATTRIBUTE-NAME-2": {
"type": "string"
},
"ATTRIBUTE-NAME-3": {
"type": "string"
}
},
"required": ["ATTRIBUTE-NAME-1", "ATTRIBUTE-NAME-2", "ATTRIBUTE-NAME-3"]
}
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
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.
Click on the top dropdown and select the option for some products depending on a condition.
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.
Under Product condition > Product attribute name, select the product attribute that you want to use for the condition.
Select the operator under equals.
Enter the numerical or text value with which the attribute is compared in the gray field.
3. Assign a value to a product attribute
Under set product attribute, select the product attribute that you want to overwrite with the value.
Enter the numerical or text value with which the attribute is compared in the gray field.
To use input from user answers, click on Answer value.
To use product attributes, click on Product attribute value.
To use variables, click on Variable value.
✏️Example: Assign text + costing 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
Set the rule trigger to depending on a condition.
Click on Select a condition > If a particular question is selected.
Under Select a condition, select the question about the wall surface.
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.
For if yes select Select an action > Set product attribute to text.
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
Within the action, select the option for some products depending on a condition.
The text should not appear for all products, but only for the colors.
Select Select a product condition > If a product attribute is > / < / = /… a number.
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.
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.
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 buckets8. 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
Save your work status and switch to the Result Page workbench area.
Select the Additional Data element in the Product Sections tab.
Select the storage attribute under DataSource Column.
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.