Import categories in Tweakwise

If you want to transfer a large amount of product information between your platform and Tweakwise, you can use a specially formatted file to import that data. Tweakwise uses the XML format to perform this task. This is called the XML feed.

In this guide, we'll build a seperate category feed together:

  • Basic structure
  • Adding categories
  • Import the feed

You can view the full example feed at the bottom of the page.

💡

Tip

The recommended method to get your product data into Tweakwise is by generating a feed with products and categories combined. To learn more, go to Create an XML feed to import your catalog data in Tweakwise.

Basic structure

The basic structure

<?xml version="1.0" encoding="utf-8"?>
<tweakwise>
  <categories>
    <!-- -->
  </categories>
</tweakwise>

Adding categories

Now we will add categories inside the categories element. For each category a 'category' element should be added. A category has the following required properties:

PropertyTypeMax lengthDescription
categoryidnumeric/alphanumeric-/50a unique identifier of numeric characters by default. If you need to use alphanumeric characters, contact our support team
namealphanumeric500the name of the category
ranknumeric-a number to determine the sequence of the category
parentslist-IDs of the categories which are parents of the category

Let's start with writing the root category, this is where the tree starts. Only one root category is allowed. We'll recognize the root category because it doesn't have parents. The XML for a root category looks like this:

<category>
  <categoryid>1</categoryid>
  <name>root</name>
  <rank>0</rank>
</category>

Let's add this category to the XML we have built until now and add two main categories 'Clothing' and 'Accessories'.

<?xml version="1.0" encoding="utf-8"?>
<tweakwise>
  <categories>
    <category>
      <categoryid>1</categoryid>
      <name>root</name>
      <rank>0</rank>
    </category>
    <category>
      <categoryid>234</categoryid>
      <name>Clothing</name>
      <rank>1</rank>
      <parents>
        <categoryid>1</categoryid>
      </parents>
    </category>
    <category>
      <categoryid>567</categoryid>
      <name>Accessories</name>
      <rank>2</rank>
      <parents>
        <categoryid>1</categoryid>
      </parents>
    </category>
  </categories>

Import

In Tweakwise App > Connectivity > Tasks you should create a new import task with Import type set to Import categories only.

Make sure this task is executed beforethe products import task, using the task chaining option. This is necessary because the product import has a dependency on this category import.

Good to know

  • Only one root category is allowed.
  • A category id can contain both letters and numerals.
  • If you don't have a basic understanding of XML, we recommend reading XML for the uninitiated.
  • This tutorial will guide you in generating a feed in any programming language or tool, as long as you know how to write text to a file using that language or tool. It will also help you manually create a feed if needed.
  • To increase readability, the examples contain different levels of indentation>> and newlines. This is not required in your feed. Removing tabs and newlines can make the feed size smaller and have impact on the performance of the import.
  • It is best practice to apply CDATA sections to all fields containing text. For example, image and url elements usually contain characters like an ampersand (&). To increase readability in this guide we omit this from some elements.