Example XML & CSV Files

Example XML & CSV Files

When importing Simple or External/Affiliate Products, WP All Import can import any XML or CSV file to WooCommerce. You don』t need to structure your file in a certain way or have specific column or element names for the import to work properly.

Special requirements only exist when importing variable products.

Download Example Files

File Structure

If you』re manually creating a file, we recommend using Excel to create a CSV. Put one product per row.

Example File

Syncing Stock Levels

Syncing Stock Levels

You』ve imported all of your products into WooCommerce. You have a separate XML or CSV file containing your stock levels, and you want to synchronize the stock levels on your site with the stock levels in your XML or CSV file.

You only need these instructions if you have a separate file with stock levels. If the same file you used to import your products also contains your stock levels, just use the Re-Run Import option. 

Each record in your stock level feed must contain the stock quantity or status, and an identifier that will allow WP All Import to assign the correct stock level to the correct product. Usually, this will be the product』s SKU.

Stock Record

Use the following settings in Step 1 of WP All Import.

Import Stock Levels

Note that we』ve specified the URL to our stock levels file. Later, this will allow us to set up a cron job to automatically download and import the stock levels from this URL, every day.

Continue to Step 3, and set your Stock Qty in the Inventory tab of the WooCommerce add-on. You can leave all other settings and sections of Step 3 blank, or at the default values. The Product Type, for example, can be left at Simple product, even if you are updating stock for other types like Variable products. The only settings that WP All Import will pay attention to are those related to product stock.

Step 3 Stock Settings

Now continue to Step 4. WP All Import may warn you that your post title and content are blank, but you can ignore this. We don』t need to import post titles and content, only stock levels.

In Step 4, it』s time to specify how WP All Import knows which product a stock level in a particular row or record in your XML or CSV file should be assigned to.

We do this using the SKU. Our file contains the SKU that each stock level is associated with. Using the following settings, we tell WP All Import that for each record or row in our file, it should search for a Product containing an _sku Custom Field with the value in our file』s SKU column, and then import data into that Product based on the options we specified in Step 3.

Record Matching

Now we need to tell WP All Import to only update our product stock levels. WooCommerce stores these stock levels in Custom Fields called _stock and _manage_stock.

When the import is run, WP All Import needs to leave everything else alone. To do that, we use the Choose which data to update option.

You』ll also notice I』ve unchecked the Create new and Delete options, since we only want to import into existing Products.

Only update stock

I』ve chosen to only update the _stock and _manage_stock Custom Fields.

Run the import, and your Products will now show the updated stock statuses and quantities.

You can easily configure WP All Import to automatically re-check the stock XML or CSV file at a specific interval to keep your product stock levels always up to date, using cron jobs.

Note: If you remember, in Step 3 in the WooCommerce add-on, we left 「Simple Product」 as the Product Type. Notice that the Product Type box is left unchecked. This allows WP All Import to import stock levels to both simple and variable products at the same time, or just variable products, without updating their Product Type based on our selection in Step 3.

Updating Prices

Updating Prices

Updating prices is done basically the same way as updating stock levels. There are only two differences.

1. Instead of specifying the stock levels, specify the prices in the WooCommerce add-on.

2. Instead of entering in the field names for stock levels, specify the correct Custom Field names for prices in Choose which data to update in Step 4.

How To Import Variable WooCommerce Products

How To Import Variable WooCommerce Products

In-Depth Tutorial

About these docs: We have a few video tutorials covering different use-cases below. To learn more about the other features of the WooCommerce add-on such as syncing stock levels, use the documentation menu to the right. Below the videos is also text documentation explaining the same things as the videos – so watch if you prefer videos, or read if you prefer text. We recommend the videos!

Part 1: Importing Variations From CSV or XML

Part 2: Importing Variations Stored As Child Elements from XML

You』ll notice that in the above tutorial, I only import from CSV files. However, importing from an XML file that is structured in a similar way to a CSV file is exactly the same. For example, if your XML file contains many elements, and each element contains either a different product or variation, then the process is exactly the same.

However, some XML feeds store their variations as children of the main product element, for example:

10027105
Adidas
Adidas Mens Climacool Boat Lace Shoes - Sale
...
...
Footwear
Casual
Men's
...
...
...
74.99
59.99

19301
0886833708180
8
Dark Indigo
74.99
59.99
...

...

In this case, the next video tutorial explains what to do.

Part 3: Setting Up An Excel File To Import Product Variations

Maybe you want to manually create a file containing your variations, because you don』t already have a point of sale or inventory management system that does it for you, or don』t have a product feed from a dropshipper or affiliate network. Sad days… but here』s how to do it, using Excel:

Now for the text documentation…

When importing variations with WP All Import, choose 「Variable Product」 in the WooCommerce add-on in Step 3 of WP All Import.

Then, you must configure three things:

General tab: you must specify the price. WooCommerce won』t show variations on the frontend of your site unless the price is present.Attributes tab: here you specify the variation attributes – for example Size or Color.Variations tab: here you specify how WP All Import links multiple variations from your XML or CSV file together to form a single variable product.

It is highly recommended that you watch the video above before reading onward, as the video will give you a big picture overview of how to import variations, while you can learn the specific details below.

Linking Multiple Variations Together To Form A Variable Product

WooCommerce stores a variable product as a single 「parent」 product, with multiple 「child」 variations.

For example, a T-Shirt might have three 「child」 variations – Small, Medium, and Large.

WP All Import can import XML and CSV files that contain parent products with child variations, and it can also import files that only contain product variations, with no parent products.

On the Variations tab of the WooCommerce Add-On, you specify how WP All Import groups multiple product variations into a single variable product. Typically, for CSV files, you』ll have one product variation per row, and for XML files, one product variation per record.

Example A – Linking Variations To Parent Based On Parent SKU

Link to parent based on SKU

In this example, you』ll notice there are two products (a mug and a t-shirt), with two variations each (based on Color).

In this example our file contains both the parent products and the variations.

The variations are grouped to their parent products using the SKU and Parent SKU columns. We can use the Parent SKU column to tell WP All Import to assign the variations to the parent product that has an SKU that is the same as the variation』s Parent SKU.

Download: CSV · XML

Example B – Product Variations Grouped By A Unique Identifier

Variations by Group ID

In this example, you』ll notice there are two products (Coca Cola and Sprite), with four variations each (based on Size).

The variations are grouped together with the Group ID column.

We can use the Group ID column to tell WP All Import to group all the variations with the same group ID into a single variable product.

In this example our CSV file contains only variations. There are no parent products, but since WooCommerce requires parent products, WP All Import will automatically create the parent products for us.

Download: CSV · XML

Example C – Variations Grouped By Title

Matched by Title

In this example, you』ll notice there are two products (Steak and Lamb), with three variations each, based on Weight for the Steak, and Quantity for the Lamb.

The Quantity attribute will be ignored for the Steak, and the the Weight attribute will be ignored for the Lamb.

In this example our file contains both the parent products and the variations.

The variations are grouped together by title. We can use the Product Title column to tell WP All Import to assign the variations to the parent product that has the same title.

Download: CSV · XML

Example D – Variations Grouped By Title, No Parent Products

Match by title, no parents.

In this example, you』ll notice there are two products (Apple tree and Orange tree), with four variations each, based on the tree height and type of rootstock.

In this example our file contains only variations, without parent products. WP All Import will automatically create the parent products.

The variations are grouped together by title. We can use the Product Title column to tell WP All Import to create multiple variable products, with each one containing all the variations with the same title.

Download: CSV · XML

Example E – Variations As Child XML Elements

If you are importing an XML file and the variations are child elements of your product elements, instead of separate product elements, use this option.

In the example XML below, you can see all variations of a product are enclosed in a element, where one product can have any number number of variants.

10027105
Adidas
Adidas Mens Climacool Boat Lace Shoes - Sale
...
...
Footwear
Casual
Men's
...
...
...
74.99
59.99

19301
0886833708180
8
Dark Indigo
74.99
59.99
...

...

When importing variations in this format, you don』t need to set anything in the General tab or the Attributes tab. You set the price and the attributes in the Variations tab.

For WP All Import to detect the variations, you must define the XML elements that contain them. You can do this by dragging & dropping one of the elements to the Variations XPath box.

Variations by XPath

You then set your attributes by dragging & dropping attributes from the popup XML tree containing the XML for the variation, instead of using the main XML tree.

You can set your price using the price in the popup XML tree if available, or if you want to set all the variation prices to the price of the parent product, you can drag the price from main XML tree. When dragging XPath from the main XML tree to any of the boxes below Variations XPath, you must check the XPath from Parent option.

Mapping XML child variations

In the screenshot above, you can see there are 10 total variants of the current product. Configure the options for just one, and WP All Import will automatically loop through the other 9 variations and create variations for all of them.

Configuring Variation Attributes

Attributes are those things that users can change to choose the variation they want. Each attribute can have multiple possible values – users select these values to choose the particular variation they want to purchase. For example, a T-Shirt could have Color and Size attributes.

Variation selections

In the example above, the two Attributes are Size and Depth. Attributes can be configured on the Attributes tab of the WooCommerce add-on.

Importing Attributes

Additional Information On Attributes

If your file has many types of variable products with different attributes – for example, t-shirts in your file have Size and Color attributes, and paintings and posters have Canvas Size and Depth attributes,  in the same file, just configure all the attributes in WP All Import. WP All Import will ignore the attributes when they don』t exist for a particular product in your file. So you won』t end up with t-shirts with Canvas Size and Depth attributes, or posters with Size and Color attributes.

Some attribute names are reserved. For example, you can』t use 「Type」. If you can』t use a certain attribute name inside of WooCommerce, you can』t use it inside WP All Import either.

Additional Information

Importing Simple And Variable Products At The Same Time

Configure your import as if you were only importing variable products.

WP All Import will automatically create simple products for products that have no variations or only a single variation.

Using Link All Variations

On the Attributes tab, you』ll notice a Link All Variations option. Use this option if the data for your variations is stored all in a single row. It works just like the Link All Variations option inside WooCommerce.

Link all variations

In above example, 『Baseball Cap』 is a product with 3 color variations and 『Mug』 is one with 2 color variations.

Each color is separated by a pipe symbol – 「|」.

Using the settings below, the WooCommerce add-on for WP All Import will automatically generate variations for each color.

If your file is using something other than a | as a separator, you can use a PHP function to replace the it with a |.

For example, if you had a Color column containing 「Red,Blue,Green」, you』d replace the commas with pipes like this:

[str_replace(",", "|", {Color[1]})]

Link all variations settings