Article

Import Product Attributes into Magento

I have recently taken on a new web project which is to move an e-commerce website from a custom 3rd party solution over to Magento and before I even got started I hit a road block (you have got to love Magento for that!).  I found that I had to import around 200 product attributes (colours, sizes, etc) from the old online shop to the magento installation and obviously I did not want to enter all these by hand, but where to begin?!

Luckily I came across a post on the Magento forums which details a method for bulk importing product attributes into Magento and although it did not allow me to automate the whole process, it was sufficient for my purposes.

The sample code provided in the post allows you to import multiple attributes into Magento but you have to create the attribute in Magento manually before you can import the values as the import does not create non-existing attibutes.  The other problem for me was that the sample code only allowed you to import one attribute at a time and then you had to edit files and id's to do the next one.

As I had multiple attributes to import I tweaked the example code (you can download the tweaked code here) to allow me to import values for multiple attributes at one time.  I still had to create the attributes manually within Magento first but the tweaked code allowed me to import all my attributes values for multiple attributes at once.

In order to import the product attribute values you need to create files in your magento installation within the folder

/var/import/attributes/

The files need to be in the format of [attribute_id]_[attribute_name].csv i.e. 80_color.csv, 122_size.csv, techically the _[attribute_name] is not necessary but it helps to make identifying which attribute the file is for a whole lot easier.

Each value for the product attribute need to be in a separate line and the first line needs to contain the word "admin".  For example, 80_color.csv contains:-

admin
Red
Blue
Green
Purple
Black

Once you have created the attribute files and copied to other files to their relevant locations you can then open ImpAttributes.html"/uploads/legacy/magento-attribute-import-sample.zip">Importing Product Attributes into Magento - Sample Code

References

Bulk Import Attributes - Original solution provided by Srinigenie

me.jpeg

I am a web developer specialising in web driven applications using PHP, MySQL, Symfony and Zend and I am currently working for the The Drum in Glasgow, Scotland.

Most days I can be found frantically coding away with EuroDance in my ears and consuming what I hope to be a never ending supply of coffee... happy days!

Chris's Reading List

verraes.net

verraes.net

Sensible Interfaces

Sensible Interfaces

How did we get from 'Program to an interface, not to an implementation' to 'Just slap an interface on there, it's the fashionable thing to do'? Read more

Moz

Moz

The Linkbait Bump: How Viral Content Creates Long-Term Lift in Organic Traffic - Whiteboard Friday

The Linkbait Bump: How Viral Content Creates Long-Term Lift in Organic Traffic - Whiteboard Friday

A fantastic piece of content can lift your traffic curves to a "new normal." In today's Whiteboard Friday, Rand talks about exactly how that happens, and how you can create content that has that effect. Read more

Loige

Loige

6 Rules of thumb to build blazing fast web applications (server side)

6 Rules of thumb to build blazing fast web applications (server side)

In this post are described 6 extremely important rules you should take under consideration when writing your next web application Read more

SitePoint

SitePoint

Console Wars - PHP CLI Libraries

Console Wars - PHP CLI Libraries

Nicola Pietroluongo compares three popular PHP console libraries, building the same functionality in each. Wondering which one is right for you? Find out! Read more

TechCrunch

TechCrunch

Servers.com Brings Its Bare-Metal Servers To The US

Servers.com Brings Its Bare-Metal Servers To The US

Servers.com, a hosting company with a focus on dedicated bare-metal servers that launched in Europe in 2005, today announced the opening of its first U.S... Read more

Blonde

Blonde

PHP in a JavaScript world

PHP in a JavaScript world

What is the fate of PHP in a JavaScript-dominated world? Will the two continue coexisting? Stephen Heron, PHP Developer at Blonde, shares his thoughts. Read more

Advertisement

Digital Ocean