Rule: Rewrite#

The rule is used to modify the values of any element, such as product names, categories, descriptions, and many more. With the Rewrite rule, you can completely replace values, enrich them, or remove parts of them.

Extra features#

  • Smart paste mode - bulk copy and paste values, for example from Google Sheets
  • In the New value field, you can enter:
    • text
    • a variable, for example: %g:brand%
    • a combination of text + variable, for example: %g:price% CZK
    • an empty value
  • Option to add multiple rows
  • Row order matters - rules are applied from top to bottom

Practical examples#

Example 1 – Enriching product names#

Enriching product names with additional information (brand, parameters).

1. Creating a new rule:

  • Open the “Rules” page.
  • Click the New rule button.

2. Selecting the rule type:

  • In the Rule type field, select the Rewrite option.

3. Selecting products:

  • In the Query field, choose either All products or create your own Product query for specific products you want the rule to apply to.

4. Choosing the element to change:

  • In the Element field, select the element you want to modify.

5. Enter the new value:

  • In the New value field, enter a combination of variables separated by spaces. For example, %brand% %title% %size% %material% %color%

6. Naming the rule:

  • In the last step, enter the rule name, for example: Enriching product names.

Example 2 – Filling an empty element#

Filling an empty required element with a value:

  • A: insert text (for example: a specific manufacturer)
  • B: insert a variable (for example: manufacturer)
  • C: combination of text and variable (sale price with currency)

1. Creating a new rule:

  • Open the “Rules” page.
  • Click the New rule button.

2. Selecting the rule type:

  • In the Rule type field, select the Rewrite option.

3. Selecting products:

  • In the Query field, choose either All products or create your own Product query for specific products you want the rule to apply to.

  • Choosing the element to change:

    • In the Element field, select the element you want to modify.
  • Enter the new value:

    • In the New value field, enter
      • a text value, for example: a specific manufacturer (Nike)
      • a variable, for example: %manufacturer%
      • a combination of variable and text, for example: %g:price% CZK
  • Naming the rule:

    • In the last step, enter the rule name, for example: Filling empty elements.

Example 3 – Removing the value from an element#

Removing the value from an element (deleting the element value).

1. Creating a new rule:

  • Open the “Rules” page.
  • Click the New rule button.

2. Selecting the rule type:

  • In the Rule type field, select the Rewrite option.

3. Selecting products:

  • In the Query field, choose either All products or create your own Product query for specific products you want the rule to apply to.

4. Choosing the element to change:

  • In the Element field, select the element you want to modify.

5. Enter the new value:

  • Leave the New value field empty. This will delete all values of the selected element.

6. Naming the rule:

  • In the last step, enter the rule name, for example Delete element.

FAQ#

What exactly is the Rewrite rule for?#

The rule is used to fully modify the content of any element in the feed. It allows you to either completely rewrite the value, enrich it with new information (e.g., add a brand, parameters, text), or delete it.

Can I use the Rewrite rule to add information to the product name, such as the brand and color?#

Yes. In the “New value” field, enter a combination of variables, e.g.: %brand% %title% %color%. Mergado will automatically insert the corresponding values from each product’s elements.

What happens if one of the variables used has no value?#

If the element is empty, Mergado will skip it during the rewrite.

If an empty variable is in the middle of a string, two spaces may remain between neighboring variables. You can easily fix this with the Find and Replace rule – enter two spaces ( _ _ ) in the “Find” field and leave a single space ( _ ) in the “Replace” field.

What is the difference between text and a variable in the “New value” field?#

Text is fixed content that is written exactly as you type it (e.g., “Nike” or “Special offer”). Variable is a reference to the value of another element, e.g., %manufacturer% or %g:price%.

How do I set up a rule if I want to completely delete an element’s value?#

Create a new rule of the Rewrite type, select the relevant element, and leave the “New value” field empty. This will remove the value from this element for all products the rule applies to.

Can I rewrite the value only for selected products?#

Yes. In the “Query” field, choose whether the rule applies to all products or only to a selected product query. The query can be based on brand, category, or price, for example.

What is smart paste mode?#

Smart paste mode allows you to bulk copy and paste multiple values (e.g., columns from Google Sheets or Excel) directly into the rule table. Mergado automatically splits the pasted values correctly by rows and columns.

How does row order work in the Rewrite rule?#

The order matters – Mergado processes rows from top to bottom. If two rows modify the same element, the result from the last (lowest) row is used.

How do I check if the rule was applied correctly?#

After saving and applying the rules or regenerating the feed, open the product preview and check whether the values changed as expected. For a detailed check of a specific product, you can enable the “Rule walkthrough” feature, which shows how individual rules progressively modify the product’s data.

Can I combine the Rewrite rule with other rules, such as Find and Replace?#

Yes. However, keep in mind that rules are applied from top to bottom and their order matters. Remember that the Rewrite rule can completely or partially rewrite an element’s value, so it is important to carefully consider its placement among other rules.

Can I use the same rule for categories or product descriptions as well?#

Yes. The Rewrite rule can be used for any element – e.g., g:description, g:product_type, g:brand, etc. The principle remains the same: select the element, enter the new value, and Mergado will write it.

Can I use the Rewrite rule to fill in a missing manufacturer?#

Yes. In the “New value” field, enter either fixed text (e.g., “Nike”) or the variable %manufacturer% if you already have this information in another element. The rule will then fill in the value for all products without a manufacturer.

What if I want to rewrite values only in empty elements without changing those that already contain data?#

In that case, create a product query where the given element is empty and apply the Rewrite rule to it.

How does the Rewrite rule behave when inserting text with diacritics or special characters?#

Mergado preserves diacritics and special characters; there is no need to remove them. If the system reports a format issue, you can use the Remove diacritics rule before the rewrite.

Is it possible to Rewrite multiple elements at once within a single rule?#

Yes. List each element on a separate row of the rule. For example: the first row for g:title, the second for g:description, the third for g:brand.

Can I use this rule to set a value from another project or feed?#

Not directly. The Rewrite rule works only with data within a single project. To import values from an external source, use the Import data file (CSV / XML) rule.

Can I schedule the Rewrite rule to run only on specific days or times?#

Yes. In the rule settings, use the “Timer” feature. You can select specific days of the week, time slots (e.g., 08:00–12:00), or set a one-time validity period from–to. Example: You can activate the Rewrite rule only during a weekend campaign – e.g., from Friday 18:00 to Sunday 23:59.

Can I add a custom note to the Rewrite rule?#

Yes. In the “Note” field, you can add any text up to 2,000 characters. It is recommended for internal comments – e.g., why the rule was created or what exactly it modifies. The note is not displayed in the feed; it is only for clarity within the project.

🇨🇿 🇬🇧 🇩🇪 🇭🇺