Rule: Bulk Rewriting by Values#
This rule allows you to modify or completely rewrite element values based on values in another element. It can be used for automatic updating or assignment of values depending on values in other fields – for example, when assigning Google categories based on online store categories.
Extra features#
- Regular expression support
- Bulk copy values, for example from Google Sheets
- New values can include:
- plain text
- a variable
- an empty value
Practical examples#
Example 1: Set Google categories based on online store categories#
This example shows how to use the Bulk Rewriting by Values rule to set different Google categories based on the online store category element.
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 Bulk Rewriting by Values 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 search by:
- In the left column in the Element to search in field
- from the Selectbox, select the element to search by
- in our case, this will be the
product_typeelement
5. Choosing the element to change:
- In the right column in the Element to write to field
- from the Selectbox, select the element you want to write new values to
- in our case, this will be the
g:google_product_categoryelement
6. Enter the search value:
- In the left column, in the “If element value contains:” field, enter for each row:
- a text value, for example: the exact search value (
Gifts | Gifts for Women) or a keyword (Gifts), or - click the Prefill left side button and Mergado will prefill all existing values in the left column
- 💡 Tip: You can also use a variable or combination of variable and text in the field, but this is not suitable for our example
- a text value, for example: the exact search value (
7. Enter the new value:
- In the right column, in the “This value will be written to the element” field, enter for each row:
- a text value, for example: the selected Google category (
Arts & Entertainment > Party & Celebration > Gifts) - 💡 Tip: For selected Mergado formats, Mergado can load values from the official category tree, simplifying category mapping.
- 💡 Tip: You can also use a variable or combination of variable and text in the field, but this is not suitable for our example
- a text value, for example: the selected Google category (
8. Naming the rule:
- In the last step, enter the rule name, for example “Set Google categories”.
Additional uses#
- Rewrite output categories based on online store categories
- Fill in custom_label elements based on various parameters
FAQ#
What is the Bulk Rewriting by Values rule for?#
This rule allows you to change or rewrite values of one element based on values in another element. More precisely, the logic works like this: If element A contains value X, then write value Z into element B. For example, you can set Google categories based on online store categories or fill in custom_label tags based on parameter values.
What is the difference between rewriting by queries and by values?#
- By queries: You determine which products to change using your own saved product queries.
- By values: You determine what to change based on specific values of another element (e.g., text in a category, brand, parameters). The rule thus automatically identifies products by the content of the selected element.
How do I select which element to search by?#
In the left column, select the element whose values will be used to find matches – for example, product_type, category_text, or PARAM|PARAM_NAME. Mergado uses these values to decide which products should receive the new value.
How do I select the element to write new values to?#
In the right column, select the element where the values will be written. For example, when mapping categories, select g:google_product_category.
Can I use partial text matching in the rule?#
Yes. In the “If element value contains” field, enter just part of the text (e.g., “Gifts”). Mergado will then find all products where this value appears anywhere in the text of the element. For an exact match, enter the full text (e.g., Gifts | Gifts for Women).
How can I load all existing values from the element I want to search by?#
Click the “Prefill left side” button – Mergado will automatically load all existing values of the selected element from the input feed. You can then manually edit this list, remove unnecessary rows, or add new ones.
Can I use regular expressions for searching values?#
Yes. After enabling the “Regular expressions” option, you can use advanced patterns (regex) for text searching. For example:
^Gifts.*→ finds all values starting with the word “Gifts”.*Child.*→ finds all values containing the words “Child”, “Children”, etc.
What can I enter in the “This value will be written to the element” field?#
In the right column, you can enter:
- text – e.g.,
Arts & Entertainment > Gifts > For Women, - a variable – e.g.,
%category%, - or a combination of both, e.g.,
%category% -- Extended set.
💡 If you want to remove the value, leave the field empty.
What happens if a product does not match any of the conditions listed in the left column?#
The product remains unchanged – Mergado does not find a matching value for it and makes no modification.
How is row order evaluated in the rule?#
Mergado applies the rule from top to bottom. If a product matches multiple conditions, the value from the last matching row is used. Therefore, row order affects the resulting element value.
How can I use the rule for mapping categories to Google categories?#
- In the left column, select
product_typeorCATEGORYTEXT. - In the right column, enter the corresponding
g:google_product_category.
💡 Mergado can load the official Google category tree, so you can select from the autocomplete the correct categories by keyword.
Can this rule be used to fill in values other than categories?#
Yes. The rule can be used for any value pairing between elements – e.g.:
- assigning
custom_labelbased on margin, - filling in
shipping_labelbased on country, - filling in
conditionbased on text in the product name.
Can I use this rule to remove element values?#
Yes. If you leave the field empty in the right column, Mergado will delete the corresponding values from the given element. This is useful, for example, when cleaning incorrect or duplicate data.
How can I check if the rule was applied correctly?#
After saving and applying the rules or after regenerating the feed, open the product preview or use the Rule walkthrough. This feature shows how individual values change after the rule is applied and allows you to verify the correctness of assignments.
Can the rule be scheduled to run only on specific days (e.g., for seasonal categorization)?#
Yes. Using the Timer feature, you can specify specific days, hours, or date ranges when the rule should be active. 💡 Example: Activate the rule only during a seasonal sale period – e.g., from December 1 to 15.
What happens if I accidentally enter a wrong element name or non-existent variable?#
If Mergado does not recognize the variable, it will not write any value and the row is skipped. Incorrect variables are highlighted with a red background in the interface. It is recommended to test the rule on a smaller sample of products using the Rule walkthrough.
How do I handle duplicate values in the left column?#
If the same value appears multiple times, the first occurrence from the top is used. Mergado processes from the first row down – subsequent matching expressions are ignored.
Can the rule be used for mapping parameters (e.g., converting parameter names to standardized ones)?#
Yes. In the left column, select PARAM|PARAM_NAME and in the right column, again select PARAM|PARAM_NAME or another target element. This allows you to unify parameter names, e.g., “Size” → “Size”, “Colour” → “Color”.
Can I import values in bulk from a spreadsheet (e.g., Google Sheets)?#
Yes. The rule supports smart paste mode – you can copy value pairs (e.g., left and right columns) directly from Google Sheets. Mergado automatically splits the values correctly by rows and columns.
How do I use exact matching in the Bulk Rewriting by Values rule?#
You can find instructions on our forum in the article How to use exact matching in the Bulk Rewriting by Values rule.