# Rewrite

**URL:** <https://forum.mergado.com/t/rewrite/491>\
**Category:** Rules\
**Created:** [June 24, 2022, 12:51pm UTC](https://forum.mergado.com/t/rewrite/491 "2022-06-24T12:51:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![petrmindl](https://forum.mergado.com/user_avatar/forum.mergado.com/petrmindl/32/25_2.png) [@petrmindl](https://forum.mergado.com/u/petrmindl)\
**Post date:** [June 24, 2022, 12:51pm UTC](https://forum.mergado.com/t/rewrite/491/1 "2022-06-24T12:51:56Z")

</div>

In this post we will learn:

- What is the Rewrite rule used for?
- How does it work?
- Examples of use
- Summary

## What is it used for?

The rule is used **to modify the values of any element** , e.g. product names, categories, labels and many others. Using the Rewrite rule, values can be completely overwritten, enriched, or reduced by parts.

 ![image](https://forum.mergado.com/uploads/default/original/2X/7/7bf760fbfff4af21c01702044cb20cc309785294.png)

## How does the Rewrite rule work?

In this section, we will describe how the rule works, what it can do, and what to watch out for.

### Basic principle

The rule targets all values of the element in the left field and completely overwrites them with the values in the right field.

Before:

```auto
<PRODUCTNAME>Phone</PRODUCTNAME>
<PRODUCT>Nokia 5800 XpressMusic</PRODUCT>

```

Rule:

 ![image](https://forum.mergado.com/uploads/default/original/2X/8/8144fbea70d03c1a5137335a02680eda59ff1993.png)

After [regeneration](https://forum.mergado.com/t/we-have-added-a-regeneration-scheduler-to-the-mergado-editor/772):

```auto
<PRODUCTNAME>Nokia 5800 XpressMusic + free shipping</PRODUCTNAME>
<PRODUCTNAME>Nokia 5800 XpressMusic</PRODUCT>

```

### The rule applies changes line by line

Within one rule, it is possible to overwrite multiple elements, so that we do not have to create a separate rule for each element.  
In such cases, the element on the 1st line is overwritten first, and only after this element is overwritten does the rule start overwriting the element on the 2nd line. And in this way the rule continues until the last line.

 ![image](https://forum.mergado.com/uploads/default/original/2X/1/16b8b273427704b37b6e4e1b6b755f6fb624ca27.png)

### What else does the Delete Parameter Values rule form offer?

The rule form offers several functions that will make our work easier:

1. **The order of the rows can be changed** by grabbing the arrow and then dragging it to the desired location.  
&nbsp;  
 ![drag-and-drop](https://forum.mergado.cz/uploads/forum.mergado.cz/original/2X/a/a45287101eb751aed09d9e7efa903eb4aa2abea6.gif)

2. **smart insertion** works in the form. If we have elements and new values listed in the table, we can simply copy them and then paste them into the form.  
&nbsp;  
 ![smarte-paste](https://forum.mergado.cz/uploads/forum.mergado.cz/original/2X/6/6245358dd3383330a1e2ccbddc4ca4d5033a5168.gif)

## Usage examples

We will show several examples of using the Rewrite rule in the [Heureka](https://www.mergado.cz/tema/heureka-cz) format.

**Example 1** : We set a fixed price - this is the `PRICE_VAT` element.

 ![image](https://forum.mergado.com/uploads/default/original/2X/0/0676e924db2cdf7cfc467dd34171b892dbc4deb3.png)

After regeneration, we will see the price we defined for the given products.

**Example 2** : We will remove the gift - this is the `GIFT` element.

 ![image](https://forum.mergado.com/uploads/default/original/2X/b/b3f863d36be915105e60d9a3ac9671d50833df21.png)

If you do not fill in the text field on the right, the element on the left will be empty (its value will become _empty_).

**Example 3** : In the `PRODUCTNAME` element, we get the same thing as in the `PRODUCT` element, and in addition, we add “+ free shipping” as the value

 ![image](https://forum.mergado.com/uploads/default/original/2X/8/8144fbea70d03c1a5137335a02680eda59ff1993.png)

## Summary

- What is it used for?  
The rule is used **to modify the values of any element** , e.g. product names, categories, labels and many others. Using the Overwrite rule, values can be completely overwritten, enriched, or reduced by parts.  
&nbsp;
- How does the rule work?  
The rule targets all values of the element in the left field and completely overwrites them with the values in the right field.

---

<div class="post-metadata">

**Author:** ![petrmindl](https://forum.mergado.com/user_avatar/forum.mergado.com/petrmindl/32/25_2.png) [@petrmindl](https://forum.mergado.com/u/petrmindl)\
**Post date:** [June 24, 2022, 12:51pm UTC](https://forum.mergado.com/t/rewrite/491/2 "2022-06-24T12:51:59Z")

</div>


