Um einen XML Product Feed in Shopify zu erstellen, kann die im folgenden beschriebene Vorgehensweise genutzt werden. Alternativ können hierfür auch spezielle (jedoch i.d.R. kostenpflichtige) Shopify-Plugins zum Einsatz kommen.
Kurzbeschreibung des Vorgehens:
Mittels eines speziellen Themes ermöglichen wir die Ausgabe der Produktdaten in der gewünschten XML-Struktur. Für die Erstellung einer neuen Collection sind folgende Schritte notwendig:
a) Im Shopify-Menü „Onlineshop“ —> „Themes“ —> „Code bearbeiten“ klicken

b) In „Templates“ —> „Ein neues Template hinzufügen“

c) Vorlage für „collection“ names „xml-product-feed“ erstellen

In das unter c) erstellte Collection-Template wird nun folgender Code hinzugefügt. Wichtig ist, dass vor und nach dem Code keine Leerzeilen enthalten sind.
{%- layout none -%}<?xml version="1.0"?>
<rss xmlns:g="<http://base.google.com/ns/1.0>" version="2.0">
{%- paginate collection.products by 1000 -%}
{%- assign useSEOtitle = false -%}
{%- assign useSEOdescription = false -%}
{%- assign Gtins = "" %}
<channel>
<title>{{ shop.name }} {{ collection.title | strip_html | strip_newlines | replace: '&', '&' }}</title>
<link>{{ shop.url }}</link>
<description>{{ collection.description | strip_html | strip_newlines | replace: '&', '&' }}</description>
{%- for product in collection.products -%}
{%- assign GoogleProductCategory = product.metafields.mm-google-shopping.google_product_category -%}
{%- assign Gender = product.metafields.mm-google-shopping.gender -%}
{%- assign AgeGroup = product.metafields.mm-google-shopping.age_group -%}
{%- for variant in product.variants -%}
{%- if variant.barcode != null and variant.barcode != blank -%}
{%- unless Gtins contains variant.barcode -%}
{%- assign Gtins = Gtins | append: "," -%}
{%- assign Gtins = Gtins | append: variant.barcode -%}
{%- assign Color = "" -%}
{%- assign Size = "" -%}
{%- assign SalePrice = null -%}
{%- assign SkipVariant = false -%}
{%- for option in product.options -%}
{%- if option == 'Farbe' -%}{%- capture Color -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Color' -%}{%- capture Color -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Colour' -%}{%- capture Color -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Größe' -%}{%- capture Size -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Grösse' -%}{%- capture Size -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Size' -%}{%- capture Size -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Anzahl' -%}{%- capture Size -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option == 'Material' -%}{%- capture Size -%}{{ variant.options[forloop.index0] }}{%- endcapture -%}
{%- elsif option != 'Title' -%}{%- assign SkipVariant = true %}
{%- endif -%}
{%- endfor -%}
{% if SkipVariant %}
{% continue %}
{%- endif -%}
{%- assign productTitle = product.title -%}
{%- if useSEOtitle and product.metafields.global.title_tag.size > 0 -%}{%- assign productTitle = product.metafields.global.title_tag -%}{%- endif -%}
{%- assign productDescription = product.description -%}
{%- if useSEOdescription and product.metafields.global.description_tag.size > 0 -%}{%- assign productDescription = product.metafields.global.description_tag -%}{%- endif -%}
{% if variant.compare_at_price != null and variant.price < variant.compare_at_price %}
{%- assign Price = variant.compare_at_price %}
{%- assign SalePrice = variant.price %}
{% else %}
{%- assign Price = variant.price %}
{% endif %}
<item>
<g:id><![CDATA[{{ variant.id }}]]></g:id>
<g:title><![CDATA[{{ productTitle }}]]></g:title>
<g:gtin>{{ variant.barcode }}</g:gtin>
<g:brand><![CDATA[{{ product.vendor }}]]></g:brand>
<g:description><![CDATA[{{ productDescription }}]]></g:description>
<g:link><![CDATA[{{ shop.url }}{{ variant.url }}]]></g:link>
<g:image_link><![CDATA[http:{% if variant.image.src %}{{ variant.image.src | product_img_url: 'grande' }}{% else %}{{ product.featured_image.src | product_img_url: 'grande' }}{% endif %}]]></g:image_link>
{% for media in product.media -%}
{% if media.position > 1 -%}
<g:additional_image_link><![CDATA[http:{{media.image.src | product_img_url: 'grande' }}]]></g:additional_image_link>
{% endif -%}
{% endfor -%}
<g:availability>{% if variant.available %}in_stock{% else %}out_of_stock{% endif %}</g:availability>
<g:price>{{ Price | money_without_currency | replace: '.', '' | replace: ',', '.'}} {{ shop.currency }}</g:price>
{% if SalePrice != null -%}
<g:sale_price>{{ SalePrice | money_without_currency | replace: '.', '' | replace: ',', '.'}} {{ shop.currency }}</g:sale_price>
{% endif -%}
{% if variant.taxable -%}
<g:tax>DE::19</g:tax>
{% else -%}
<g:tax>DE::0</g:tax>
{% endif -%}
<g:mpn><![CDATA[{{ variant.sku }}]]></g:mpn>
{% if Color != "" -%}
<g:color><![CDATA[{{ Color | strip_html | strip_newlines }}]]></g:color>
{% endif -%}
{% if Size != "" -%}
<g:size><![CDATA[{{ Size | strip_html | strip_newlines }}]]></g:size>
{% endif -%}
<g:item_group_id><![CDATA[{{ product.id }}]]></g:item_group_id>
{% if Gender != null -%}
<g:gender><![CDATA[{{ Gender }}]]></g:gender>
{% endif -%}
{% if AgeGroup != null -%}
<g:age_group><![CDATA[{{ AgeGroup }}]]></g:age_group>
{% endif -%}
{% if variant.weight > 0 -%}
<g:shipping_weight><![CDATA[{{ variant.weight | weight_with_unit }}]]></g:shipping_weight>
{% endif -%}
<g:condition>new</g:condition>
<g:stock>{{ variant.inventory_quantity }}</g:stock>
</item>
{%- endunless -%}
{%- endif -%}
{%- endfor -%}
{%- endfor %}
</channel>
</rss>
{%- endpaginate -%}
Hinweise zum obigen Code: