Element-Path

In this post, we will learn:

MERGADO Editor perceives elements in the same way as XML feeds do. This is the basis for all the work with elements, where we encounter, for example, nested or multi-value elements. And to be able to modify specific element values, we need to have a way to target those values. That’s what we have Element-Path for.

What is Element-Path?

Element-Path is a language, authored by us (MERGADO), that we use to write paths to elements (and their values).

What is path to element?

A path to element is a tool we use to target element values. By targeting, we mean that we either want to take a value from an element and work with it somewhere else, or we want to write to it and modify it.

Example: if we want to target a product name (e.g. the value of the NAME element), the path would be “NAME”. The MERGADO Editor reads this path and knows which element to look at and what value to take/modify.

:information_source:  In MERGADO 1, the Element-Path language could not be used, as there were no multi-value elements or element structure in that version.

Element-Path vocabulary and grammar

Since Element-Path is a language, Element-Path, like regular languages, has a vocabulary (the elements that can be used in paths to elements) and a grammar (a set of rules for how paths are written).

Example: if we compare the Element-Path language to English, then a path to an element is analogous to a sentence:

  • Different sentences with different content use the words and grammar of the English language.
  • Different paths to different elements use the words and grammar of the Element-Path language.

The names of all the elements

The Element-Path vocabulary includes the names of all elements. The simplest path is one that consists of the name of the element itself.

Example: you may have used the Rewrite rule to edit a product description, i.e. you have overridden the value of the DESCRIPTION element. This means that you have entered the text “DESCRIPTION” in the field for the element.

Nestedness

If you want to target a nested element add the element’s parent name and the vertical bar | (another addition to the vocabulary) to the path before the element.

Example: we want to target the information parameter - the NAME element nested under the INFORMATION_PARAMETER element.

image

Since the NAME element for the information parameter is nested under the INFORMATION_PARAMETER element (which is nested under INFORMATION_PARAMETERS), the path to its values looks like this:

image

The MERGADO Editor reads the path by first going to the INFORMATION_PARAMETERS element, then to its children, where it overwrites the value of the NAME element within the INFORMATION_PARAMETER element.

Conditions

The conditions in the element path are a filter that allows us to filter values for multi-value elements within the path. They are written in curly brackets { }. Conditions are an important part of Element-Path, so we recommend you read the detailed post on conditions in element paths.

Example: We want to modify the value of the Material information parameter.

image

This is a nested VALUE element and the path looks like this:

Except that the path targets all values of the VALUE element

image

and we only want to modify the value for Material. We will therefore use the condition. The final path will therefore be:

image

Special attributes

There are special attributes @@POSITION and @@VALUE. These attributes can be used in conditions. You can read more about them in the individual posts.

Example: IMGURL_ALTERNATIVE { @@POSITION >= 2 }

Example: CATEGORIES | CATEGORY { @@VALUE != "Toys" }

:bulb: If you can think of another special attribute you would use, email us!

MQL in Element-Path

We don’t stop at special attributes. In fact, we can type anything into conditions that we can type into MQL query. This adds the entire vocabulary of MQL to the Element-Path vocabulary. Again, we recommend reading the detailed post on element path conditions.

Example:
VARIANTS | VARIANT { PARAMETERS | PARAMETER { NAME = "Size" } | VALUE = "M" AND PARAMETERS | PARAMETER { NAME = "Material" } | VALUE = "Cotton" } | STOCK | WAREHOUSES | WAREHOUSE | NAME

Syntax errors

Just as you can make spelling or grammatical errors in English, you can make syntax errors in Element-Path. If we make a syntax error in our writing, MERGADO Editor usually warns us about it. As an example: omission of closing quotation marks in condition in path to element:

image

:bulb: Read the post dedicated to errors in paths to elements.

The path to element or to values?

Throughout this post we write path to element, but you may have come across path to element value or similar other forms. All of these shapes are fine. There are no rules about writing paths - it always depends on the writer’s judgement and the context of the whole text.

In general, the form path to the value of the element, i.e. with the word value, is more accurate because path targets the value of the element, not the element itself.

However, if we talk about simple elements, the path to element form is clear enough, since the element has only one value. So we know that the path targets that one value. But if we talk about multi-value elements that have multiple values, it is more appropriate and accurate to use the form with the word value if the path targets only one specific value.

Here are some examples:

  • element/attribute path,
  • element/attribute,
  • IMGURL element,
  • IMGURL element path,
  • path to value 69 of PRICE_VAT element,
  • path to parameter value,
  • path for element,
  • element path,
  • element whose path,
  • value whose path,
  • for value 69 the path is,
  • path
  • and many others.

How to read path?

The rules for reading paths to elements are not explicitly given, but we recommend following these principles to better understand how the paths themselves work, i.e. what values they target in the result of the path.

Principles of path reading:

  1. Read sequentially from left to right.
  2. We read element names and special attributes intuitively as they come to us. E.g. “element ITEM_ID” or just “ITEM_ID” etc.
  3. For unnested elements, just read “target the element” (or target the element value or all element values).
  4. For paths with nested elements, start with “take” or another synonym.
  5. We read vertical bars as “and the nested element under it” or “and its child”, etc.
  6. For the last nested element, we say “and (in such an element) target the nested element under it” or “and (in such an element) target its child”, etc.
  7. Conditions: we read the left curly bracket as “whose underlying nested element” or “whose child”, etc.

Example 1: ITEM_ID
“We are targeting the ITEM_ID element.”

Example 2: INFORMATION_PARAMETERS | INFORMATION_PARAMETER { NAME = "Material" } | VALUE
We can read it like this:

  • “Take an INFORMATION_PARAMETERS element and an INFORMATION_PARAMETER element nested under it, whose NAME element nested under it has a value equal to Material, and in such INFORMATION_PARAMETER element target the VALUE element nested under it.”
  • “Take INFORMATION_PARAMETERS and its child INFORMATION_PARAMETER whose child NAME has a value equal to Material, and in such INFORMATION_PARAMETER target its child VALUE.”
  • etc.
    ezgif.com-gif-maker

Example 3: CATEGORIES | CATEGORY { @@VALUE != "Toys" }
Let’s read it, for example, as follows:

  • “We take the CATEGORIES element and target its CATEGORY child whose value is not equal to Toys.”
  • “We take the CATEGORIES and target the submerged CATEGORY under, whose value is not equal to the Toy.”

What is Element-Path for?

Element-Path is used to write paths to elements, which we then use to target element values.

Where do we target element values?

We will use targeting element values (thus also Element-Path) when working in the MERGADO Editor in many places, in general everywhere we work with elements:

  1. In a simple selection form - Oneliner - on the Products page when creating conditions. In the first or third part of the condition it is possible to write paths to elements.
     

  2. In the form for your own MQL query.
     

  3. When sorting products on the Products page.
     

  4. In the table view products when adding columns.

    Snímek obrazovky z 2023-05-22 14-20-18

  5. In the form of some rules in the field for the element – refers to the rules Rewrite, Find and Replace, Bulk rewriting by query, Bulk rewriting by values, Bulk copy values, Truncate value, Letter case converter, Round number, Remove diacritics , Set UTM parameters, Remove HTML tags, Calculation and Add a value to a multi-value element.

    image

  6. In the headers of import files, which we upload via the rule Data file import.

  7. On the page of the values of a specific element (after clicking on the Elements page).

  8. When creating and editing variables.

    Snímek obrazovky z 2023-05-22 14-25-07

Examples of targeting

We covered dozens of examples of targeting for different formats in a separate post Element-Path: Examples of targeting (Heureka, Google, Shoptet).

Summary