Instead of using the Import API, which is more suitable for migrations, you can use Tycka’s Item Feed feature. If you run an e-commerce, chances are you already have some kind of feed of product information for services such as Google Shopping.
Tycka can import XML feeds of items with the following format but allows an XSLT transformation to be configured, which we will apply before processing the feed. This makes it possible to use almost any XML feed that contains the item information in a straightforward and standardized fashion.
<items>
<item id="jacket1">
<name>Jacket</name>
<images>
<image><https://example.com/image1.jpg></image>
<image><https://example.com/image2.jpg></image>
</images>
<tags>
<tag>shirt</tag>
<tag>clothing</tag>
</tags>
<custom-field name="colorName">Black</custom-field>
<custom-field name="colorCode">black</custom-field>
<custom-field name="size">XL</custom-field>
</item>
</items>
Import feeds are configured using an import feed configuration that contains the URL to call, the schedule on which to call it, the headers to be sent along with the call, and a field mapping.
If you are using google shopping as your item import feed, then you can use our simplified google shopping feed import. Where we provide you with a common starting point from which you can add your own custom mapping.
Here is the source XML that we want to map:
<?xml version='1.0'?>
<rss xmlns:g="<http://base.google.com/ns/1.0>" version="2.0">
<channel>
<item>
<title>Green Jacket</title>
<sku>12346</sku>
<price>120</price>
<g:google_product_category>Apparel & Accessories > Clothing (1604)</g:google_product_category>
<g:condition>new</g:condition>
<g:description>A green jacket with blue pockets</g:description>
<g:image_link><http://images.example.com/12346-1.jpg></g:image_link>
</item>
<item>
<title>Blue Jacket</title>
<sku>12348</sku>
<price>125</price>
<g:google_product_category>Apparel & Accessories > Clothing (1604)</g:google_product_category>
<g:condition>new</g:condition>
<g:description>A blue jacket with a hoodie</g:description>
<g:image_link><http://images.example.com/12348-1.jpg></g:image_link>
<g:additional_image_link><http://images.example.com/12348-2.jpg></g:additional_image_link>
<g:additional_image_link><http://images.example.com/12348-3.jpg></g:additional_image_link>
</item>
</channel>
</rss>
Using the following transformation:
<xsl:stylesheet
xmlns:xsl="<http://www.w3.org/1999/XSL/Transform>"
xmlns:g="<http://base.google.com/ns/1.0>"
exclude-result-prefixes="g"
version="1.0">
<xsl:template match="/">
<items>
<xsl:apply-templates/>
</items>
</xsl:template>
<xsl:template match="item">
<item>
<xsl:attribute name="id">
<xsl:value-of select="current()/sku" />
</xsl:attribute>
<name><xsl:value-of select="title"/></name>
<xsl:if test="g:additional_image_link or g:image_link">
<images>
<xsl:for-each select="g:image_link">
<image><xsl:value-of select="current()" /></image>
</xsl:for-each>
<xsl:for-each select="g:additional_image_link">
<image><xsl:value-of select="current()" /></image>
</xsl:for-each>
</images>
</xsl:if>
<xsl:for-each select="g:description">
<custom-field name="description">
<xsl:value-of select="current()" />
</custom-field>
</xsl:for-each>
</item>
</xsl:template>
</xsl:stylesheet>
We will end up with the following item feed:
<?xml version="1.0" encoding="utf-16"?>
<items>
<item id="12346">
<name>Green Jacket</name>
<images>
<image><http://images.example.com/12346-1.jpg></image>
</images>
<custom-field name="description">A green jacket with blue pockets</custom-field>
</item>
<item id="12348">
<name>Blue Jacket</name>
<images>
<image><http://images.example.com/12348-1.jpg></image>
<image><http://images.example.com/12348-2.jpg></image>
<image><http://images.example.com/12348-3.jpg></image>
</images>
<custom-field name="description">A blue jacket with a hoodie</custom-field>
</item>
</items>