Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Import Bulk Attributes
 
joshinaround
Jr. Member
 
Total Posts:  13
Joined:  2008-12-03
 

I too need a sample CSV import file....please!!  Cannot figure that out.

 
Magento Community Magento Community
Magento Community
Magento Community
 
avintel
Sr. Member
 
Total Posts:  147
Joined:  2008-05-15
Southern California
 
srinigenie - 02 June 2008 07:26 PM

Now place the values that you need to import in a CSV file like below and place this CSV file var/import directory and name this file importAttrib.csv

admin
AttrVal1
AttrVal2
AttrVal3
...
.
...


Now import these attribute values by accessing the URL
http://<your wesite>/ImpAttributes.php


Happy Importing :). Please let me know how this can be improved. Haven’t had the time to change it.

ok, i am sorry that i am a little lost with the directions in this thread or even if it is applicable… so any help will be appreciated.  I am sorry again if i am asking to repeat something basic.

i don’t understand what “admin” above indicates. nore attrval1,2,3? are those the attribute names i want to have?  AND FINALLY, is this thread even about “importing” attribute names (ie. color, manufacturer, etc) or the attributes themselves (ie. black, white, green, etc.) or attribute sets (ie. televisions, hand tools, make-up, electronics, books, etc.)?  I am pretty sure it is the attributes themselves.  i am going to post another thread asking for a detailed topic about creating all of these types of imports.  please contribute if you have any answers.

http://www.magentocommerce.com/boards/viewthread/36443/

 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

Thanks by the way, I’ve been using this script since v1.1.6.  and it works for v 1.3 as well.

This script is to enter the actual attributes themselves.  Another way to call it is the attribute options.

I think the “admin” is just the index value.  If you look when you enter it manually, you have two choices, “Admin” and “Default Store View”.
I think by putting admin, you put the attributes into the admin column.

These represent the individual attribute options:
AttrVal1
AttrVal2
AttrVal3

 
Magento Community Magento Community
Magento Community
Magento Community
 
avintel
Sr. Member
 
Total Posts:  147
Joined:  2008-05-15
Southern California
 

ok, if i understand this post it allows you to upload numerous options for attributes.  Is there a way to upload the actual attribute names?

Additionally, is there a way to “move” attribute values from one attribute to another?

example:

SPECIFICATIONS: 1080P

Move to/Change to

RESOLUTION: 1080P

- the only issue I have about “change to” is that I already have a “resolution” attribute.

 
Magento Community Magento Community
Magento Community
Magento Community
 
timberdawolf
Member
 
Total Posts:  40
Joined:  2009-06-04
 

strange i have done everything as stated in this thread the script executes just fine ... but when i check magento i don’t see those values under the attribute ....

 
Magento Community Magento Community
Magento Community
Magento Community
 
metaforgebrandon
Member
 
Total Posts:  57
Joined:  2009-03-26
 

Excellent Solution.  Thanks a lot.

 
Magento Community Magento Community
Magento Community
Magento Community
 
oleksi
Jr. Member
 
Total Posts:  7
Joined:  2009-05-30
 

Thanks for the solution. I’m so surprised that Magento doesn’t include this in its core functionality.

Is it hard to modify ImpAttributes.php so that it will read “Default Store View” along with “Admin” for each attribute option? I’m trying to import options for Color attribute and I need to keep color’s code in Admin column and color’s friendly name in “Default Store View” column. So my import CSV should contain two columns rather than one.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwpadgett
Member
 
Total Posts:  69
Joined:  2007-09-05
 

Is it hard to modify ImpAttributes.php so that it will read “Default Store View” along with “Admin” for each attribute option? I’m trying to import options for Color attribute and I need to keep color’s code in Admin column and color’s friendly name in “Default Store View” column. So my import CSV should contain two columns rather than one.

just add your store code (ex: default) in the second column for your color names. Use ‘admin’ for your codes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Red Mouse Computers
Sr. Member
 
Total Posts:  123
Joined:  2009-10-04
 

is there any editing to the php files that has to be done before executing the script?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Red Mouse Computers
Sr. Member
 
Total Posts:  123
Joined:  2009-10-04
 

OMG thanks for this script! it worked excellent on the 1st try. Much more simpler than i thought it would be. also for those asking for an example CSV file, here’s mine.

EDIT: my attachment isn’t uploading… sry guys.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bolasevich
Sr. Member
 
Avatar
Total Posts:  235
Joined:  2008-03-04
Newington, CT USA
 

i currently have a extension in beta testing that will do this the true magento way using magentos dataflow method and take a CSV file and import all attributes and attribute sets. I will provide a link once the extension has completed testing and gone live. Should be a few days at most, feel free to pm with questions

 
Magento Community Magento Community
Magento Community
Magento Community
 
bolasevich
Sr. Member
 
Avatar
Total Posts:  235
Joined:  2008-03-04
Newington, CT USA
 

final product with alot of testing http://www.magentocommerce.com/extension/2193

 
Magento Community Magento Community
Magento Community
Magento Community
 
subesh
Sr. Member
 
Avatar
Total Posts:  145
Joined:  2009-01-08
 

I’ve got some more on product import + import attribute + and their options here!
http://subesh.com.np/2009/11/product-import-in-magento-alongwith-updating-the-attributes-options/

 
Magento Community Magento Community
Magento Community
Magento Community
 
seanbro
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2009-03-30
 

I found the CSV method cumbersome and I couldn’t get it to work as directed. Instead, I built this PHP script where you can store attribute values in an array and insert them into your database. I believe this will only work for dropdown and multiselect type attributes. You also need to be familiar with PHP arrays to make use of this.

Instructions:
1. Create each of your desired attributes in Magento’s admin area (not the options, just an empty attribute).
2. Note each attribute ID (you can find the ID by editing the attribute after saving it and looking at the URL. The number that follows “attribute_id” in the URL is what you want.).
3. Use the attribute ID as the array key for each group of options (in my example, 498 is the ID for an attribute called “color").
4. (Optional) If you want to add a translation for an option, use the store ID as the array key for each option value (in my example, “0” is the default/admin value and “2” is my Spanish store. My manufacturers do not require an array key because I am only inserting the default/admin value.).

<?php

//Connect to DB
$db_host 'localhost';
$db_name 'magento_db';
$db_user 'magento_user';
$db_pass 'mypassword';
$db_connection mysql_connect($db_host$db_user$db_pass) or die('Could not connect to DB');
mysql_select_db($db_name$db_connection) or die('Could not select DB');

//Use the attribute ID as the array key for each set of attribute options
//Use the store ID as the array key for each attribute option value
$attributes = array(
    
//Colors
    
498=>array(
        array(
0=>'Black'2=>'Negro'),
        array(
0=>'Brown'2=>'Marron'),
        array(
0=>'Green'2=>'Verde'),
        array(
0=>'Orange'2=>'Naranja')    
    ),
    
//Manufacturers
    
499=>array(
        array(
'Sony'),
        array(
'Canon'),
        array(
'Samsung')           
    ),
    
//Sizes
    
497=>array(
        array(
0=>'Small'2=>'Pequeno'),
        array(
0=>'Large'2=>'Grande')
    )
);

//Create attribute options
foreach($attributes as $attribute_id=>$attribute_options){
    
foreach($attribute_options as $attribute_option){
        mysql_query
("INSERT INTO eav_attribute_option (attribute_id, sort_order) VALUES ($attribute_id, 0)") or die(mysql_error());
        
$option_id mysql_insert_id();
        foreach(
$attribute_option as $store_id=>$value){
            $safe_value 
mysql_escape_string($value);
            
mysql_query("INSERT INTO eav_attribute_option_value (option_id, store_id, value) VALUES ($option_id$store_id, '$safe_value')") or die(mysql_error());
        
}
    }
}

echo 'Successfully imported your attributes!';
mysql_close($db_connection);

?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Paulus
Guru
 
Total Posts:  335
Joined:  2008-07-21
 

Strange, i get this:
‹������2���ÿÿ�·ï܃���

Edit: the above is now gone, but i get some other formatting issues.
saveOptionValues(527); //527 for merken // 66 for manufacturer echo 3; } catch (Exception $e) { echo $e->getMessage(); } ?>

Will try and fix thank you.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top