Skip to main content

Content settings (XML)

XML is what most serious marketplaces want - Google, Meta, and nearly every comparison engine. It is also the format where you have the most control, because you write the structure yourself rather than filling in columns.

You rarely start from nothing, though. Take a pre-made XML template, see how it is built, and change the parts that matter to you. That is faster than reading a specification and safer than guessing.

The structure is plain XML with placeholders where product data goes.

  • Static values: hardcoded text inside XML tags. (e.g., <gender>women</gender>)
  • Dynamic values: attributes from your store (e.g., {{ product.name }}).

Understanding XML schema

Basic XML feed structure

Most shopping engines provide XML feed templates. You can modify these based on their requirements.

Example XML structure:
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
{% for product in context.products %}
<item>
<id><![CDATA[{{ product.sku }}]]></id>
<title><![CDATA[{{ product.name }}]]></title>
<price><![CDATA[{{ product.price }}]]></price>
</item>
{% endfor %}
</rss>
  • {% for product in context.products %} ... {% endfor %}: loops through all products.
  • {{ product.attribute_code }}: inserts dynamic product data.
  • CDATA blocks: prevent errors with special characters like < or &.

Using loops for data cycles

You can cycle through products, categories, reviews, tier prices, source items and configurable attributes using loops.

Product data block

Loops through all products in the feed:

Example
{% for product in context.products %}
<item>
<name><![CDATA[{{ product.name }}]]></name>
<price><![CDATA[{{ product.price }}]]></price>
</item>
{% endfor %}

Category data block

Loops through all categories:

Example
{% for category in context.categories %}
<category>
<name><![CDATA[{{ category.name }}]]></name>
</category>
{% endfor %}

Review data block

Loops through all product reviews:

Example
{% for review in context.reviews %}
<review>
<nickname><![CDATA[{{ review.nickname }}]]></nickname>
<rating><![CDATA[{{ review.rating_summary }}]]></rating>
</review>
{% endfor %}

Tier prices block

Loops through all tier prices defined for the product:

Example
{% for tier_price in product.tier_prices %}
<tier_price>
<price><![CDATA[{{ tier_price.price }}]]></price>
<quantity><![CDATA[{{ tier_price.quantity }}]]></quantity>
<price_type><![CDATA[{{ tier_price.price_type }}]]></price_type>
<customer_group><![CDATA[{{ tier_price.customer_group }}]]></customer_group>
<website_id><![CDATA[{{ tier_price.website_id }}]]></website_id>
</tier_price>
{% endfor %}

Source items block

Loops through inventory quantities from all Magento sources (e.g., warehouses) if Multi-Source Inventory (MSI) is used:

Example
{% for source in product.source_items %}
<source_qty><![CDATA[{{ source.quantity }}]]></source_qty>
{% endfor %}

Configurable attributes block

Loops through configurable product attributes (like color or size):

Example
{% for attribute in product.configurable_attributes %}
<attribute>
<code><![CDATA[{{ attribute.code }}]]></code>
<value><![CDATA[{{ attribute.value }}]]></value>
<label><![CDATA[{{ attribute.label }}]]></label>
</attribute>
{% endfor %}

Using attributes and patterns

  • Product attributes: {{ product.attribute_code }} (e.g., {{ product.sku }}, {{ product.price }})
  • Category attributes: {{ category.name }}
  • Review attributes: {{ review.nickname }}

You can use all attributes from Store -> Attributes -> Product, as well as static attributes like entity_id and created_at.

Note

Characters like < and & are illegal in XML elements.

< - will generate an error because the parser interprets it as the start of a new element.

& - will generate an error because the parser interprets it as the start of a character entity.

We suggest that you enclose all patterns in a CDATA block <attribute><![CDATA[{{ pattern }}]]></attribute>. In this case, the xml data feed will be valid.

Declaring types for the JSON copy

If the feed has Generate JSON enabled, the same template also produces the .json file - and it can say what each value is, not just what it reads. Mark an element xsi:type="xs:decimal", xs:integer or xs:boolean and it arrives as a number or a boolean; xsi:nil="true" becomes null, and xsi:type="array" keeps a field a list even when the product has only one of them. Note that the declarations are ordinary XML attributes, so they stay in the .xml file as well - they are stripped from the JSON only. See JSON output.

Validation rules (JSON)

This section contains a JSON array of field filters and is used for feed validation.

Validation rules

Example for validation rules