Rules: Then and Else Statements
Rules are a key feature in our Feeds Management tool. Each rule is divided into three parts: the "If", "Then" and "Else" sections. By utilizing these If-Then-Else statements, you can manipulate your imported data in the same way a programmer would. This article focuses on the Then and Else segment of a rule.
To learn more about the If-condition, read this article
The Then-statement lets you take action on the items you've chosen in the If-condition. For instance, if you identified items with an empty "color" in the If-condition, and you don’t want these items to appear in your export channel, you can exclude them. To do this, you will use the Then-statement. In this case, you would select all fields and set them to Exclude product from feed. Once you save this rule, the items without an “color” will be removed from the export feed.
On the right side of your screen, you can always view the results of your rules. After you save the rule, you’ll be able to see the number of items you had before implementing the rule, as well as how many items remain afterward in Item Count section
When you incorporate the Else-statement into a rule, it enables you to apply actions to items that do not fall under the If-condition. This functionality helps minimize the total number of rules you need to create.
For example, if you set a price for some product with price over $100 but add the phrase “Discount” to the product title for those below that amount, you can accomplish this with a single rule by using the Else-statement. See the image below for an example.
In the image above, all products with a price greater than 100 (as specified in the If-condition) have the phrase Discount appended to their product title using the Then-statement. All other products are labeled as "Standard price" through the Else-statement within the same rule
You can enrich the Then and Else-statement by incorporating "And". By adding "And" to your Then Else-statement, you can make several adjustments to the items specified in the If-condition. For example, if your import lacks data for both the Manufacturer and Vendor across all items, you can efficiently fill both fields with the correct values using a single rule through "And". Check the image below for a visual representation of this example
To learn more about the If-condition, read this article
Then-statement
The Then-statement lets you take action on the items you've chosen in the If-condition. For instance, if you identified items with an empty "color" in the If-condition, and you don’t want these items to appear in your export channel, you can exclude them. To do this, you will use the Then-statement. In this case, you would select all fields and set them to Exclude product from feed. Once you save this rule, the items without an “color” will be removed from the export feed.
On the right side of your screen, you can always view the results of your rules. After you save the rule, you’ll be able to see the number of items you had before implementing the rule, as well as how many items remain afterward in Item Count section
Else-statement
When you incorporate the Else-statement into a rule, it enables you to apply actions to items that do not fall under the If-condition. This functionality helps minimize the total number of rules you need to create.
For example, if you set a price for some product with price over $100 but add the phrase “Discount” to the product title for those below that amount, you can accomplish this with a single rule by using the Else-statement. See the image below for an example.
In the image above, all products with a price greater than 100 (as specified in the If-condition) have the phrase Discount appended to their product title using the Then-statement. All other products are labeled as "Standard price" through the Else-statement within the same rule
Expanding your Then and Else-statement with "And"
You can enrich the Then and Else-statement by incorporating "And". By adding "And" to your Then Else-statement, you can make several adjustments to the items specified in the If-condition. For example, if your import lacks data for both the Manufacturer and Vendor across all items, you can efficiently fill both fields with the correct values using a single rule through "And". Check the image below for a visual representation of this example
Updated on: 19/10/2024
Thank you!