By default, when importing products into magento via csv file, and you want to provide values for attributes for those products, you have to enter the attribute codes in the first line of the csv file, eg:

sku,colour,brand,custom_attribute_one,custom_attribute_two, ..etc..

This is absoloutly fine if you are using only a small number of attributes in your store.

However, when you have thousands of attributes, this becomes a problem as you would need to generate x number of rows, depending on how many you are using. So, lets say 1000 attributes = at least 1001 columns in the csv.

To export data from a database to this kind of format would be a nightmare, when the data is already normalised in the database.

So, the question is whether there is a way to import a csv containing a limited number of columns as below:


Baring in mind that both the products and attributes would already created in magento, and this step is just to populate the actual values of each attribute relating to each imported product.

So, an example csv might look something like:

sku,         attribute_code,            value
UE46F5500AK, i_944_display_diagonal,    46
UE46F5500AK, i_11424_hd_type,           Full HD
UE46F5500AK, i_1585_display_resolution, 1920 x 1080
UE46F5500AK, i_39_aspect_ratio,         16:9

Now, i assume this would have to be done via a custom, or adapted php or dataflow script, and creating an array and using each column eg:

array( sku[0] attribute_code[1] value[2] )

However, with very little php knowledge i wouldnt even know where to start. If anyone could point me in the right direction that would be fantastic, as i have no idea of any other way to import all the values

edit. I already use magmi for importing of products, however there doesn't seem to be the needed functionality for importing the above csv example, ie you still have to enter each attribute code at the first line, which with a huge number of attributes, is no feasible


2 Answers 2


The simplest way is probably to use Magmi:


This will let you update only the attributes you need to, and you can skip the ones you don't want to update or enter. So for example, if you are updating existing product, you need to only enter SKU and then at least 1 other attribute that you want updated. I think this is what you need if I understand your question correctly. If this isn't your answer, please re-word your question detailing the problem specifically.

  • Hi, yes i forgot to mention that i am already using magmi, but if you see the first example csv in my question this is what i would have to use, whereas i want to be able to use something similar to the second example csv. Dones that make sense. If not i will try expand more on my question Commented Nov 19, 2013 at 0:16

I have been struggling to get the same format for MAGMI, if you are getting the data from MS-SQL DB for example you should use "Pivot" Vertical to Horizontal Query for an unknown number of columns:-


select @cols = STUFF((SELECT ',' + QUOTENAME(attribute_code) 
                from yt
                group by attribute_code
                order by attribute_code
        FOR XML PATH(''), TYPE
        ).value('.', 'NVARCHAR(MAX)') 

set @query = 'SELECT store,' + @cols + ' from 
            select sku, attribute_code, value
            from yt
        ) x
            for attribute_code in (' + @cols + ')
        ) p '


-If you have more than one table and using joins, then you can make a view and use it in the yt (yourtable) I mentioned. After retrieving the data you can paste in csv with the same format as magmi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.