Import variable products using attributes

Variable products or product variations are a great feature of Woocommerce. To learn more about them check this. Variable products a main product, a variation master and multiple product variations. Some information is stored in the master, like categories, tags and some information is stored in the product variations, like price, stock, etc.

In order to create variations based on attributes you must first set up your attributes. You can do that in Products -> attributes.
setup attributes

In your CSV file you can add a few columns variations, pa_the_slug_of_my_attribute,pa_the_slug_of_another_attribute. If you create the attributes color and size you can try the example file.
example file

In this CSV file you have a few examples:

Variable product with one variation that you set on master level ( sku1 )
This is the simplest setup of an variable product. You add the attribute values you want on the master and have one variation that stores the price and stock. If you have a t-shirt with the colors red, green and blue. They cost all the same ( 79,- in this example file)

Variable product with one variation and 2 attributes ( sku2 )
This example shows how you can multiple attributes. Just add them in the variations column and separate them by pipe. Be absolute sure that you use the SLUG of the attribute here. (washing-instruction in stead of Washing Instruction) and it much match exactly the header. So if you have color|size|washing-instruction in the variations column you should also have pa_color, pa_size and pa_washing-instruction as header fields

Variable product with two variations with attributes set on master level and one exception ( sku3 )
If your product variations are not all the same you can make exception. So in the case you have a t-shirt and the red is cheaper than all other colors. You add a product variation and put red in the pa_color column and you will now have created an exception for the color red.

variable product with an exception

Variable product with only exception variations without attribute set up on master level and a default attribute ( sku4 )
You can also define nothing on master level and register only product variations. In this case you can control every aspect of your product variations.

A few notes:

  • If you use an attribute for variations, you can not use as a regular attribute. So if you use color as an variation, you must nut put it in the column attributes as well.
  • If you get the message attributes not found, check if the attribute is spelled correct ( as a slug ) in the variations column and the pa_xxxxxxx column.
  • pa_ stands for product attribute
  • To add default attributes put them in the column default_attributes ( see example sku4 ). Be sure to use slugs here as well.
  • A featured image can be added to a product variations just like on any other product!
  • To control it’s visibility, add ->0 to disable it. In the variation column color|size->0 means you have 2 variations and color is visible and size is not.
  • If you want to import variable descriptions, use the variation_description field
  • If you want to change the order, use the menu_order field