Magento: export attributes

Is there any way of exporting attributes from Magento? I have dropdown attributes with a couple of hundred of options each, and need to transfer them to another Magento installation. I’ve found instructions on how to import attributes from CSV, but have had no luck with exporting so far.

4 thoughts on “Magento: export attributes”

  1. Magento doesn’t have (that I know of) a competent way to export product attributes with large value lists. If the second machine is a fresh install of Magento (or you don’t mind editing a little SQL), I’d offer that you should just dump the database tables for eav_attributes and copy it into the new database.

    Hope that helps!


  2. If you create your own custom module, you can use the sql/modulename_setup scripts to import attribute values. The snippet below shows you how the code required for an attribute called “class” being added to an attribute set called “Profiles”. You could adapt it to your own attributes and sets. Refer to the wiki for more info.

    $iAttributeId = $installer->getAttributeId($iProductEntityTypeId, 'class');
    $iSetId = $profileAttrSet = Mage::getModel("eav/entity_attribute_set")
        ->addFieldToFilter("entity_type_id", Mage::getModel('catalog/product')->getResource()->getTypeId())
        ->addFieldToFilter("attribute_set_name", "Profiles")
    $aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
    $aOption = array();
    $aOption['attribute_id'] = $iAttributeId;
        $aOption['value']['option'.$iCount][0] = $aClasses[$iCount];

    You could use the eav/entity_attribute API to extract the values then populate your array above.


  3. This might help someone one day… This SQL will grab the table values for an EAV Attribute. This example is grabbing all the values for the attribute code of ‘color’

    SELECT v.* FROM eav_attribute AS a
    JOIN eav_attribute_option AS o ON a.attribute_id = o.attribute_id
    JOIN eav_attribute_option_value AS v ON o.option_id = v.option_id
    WHERE a.attribute_code = 'color';

    Just make sure that if you are going to use SQL to upload values back into the eav_attribute_option_value table that you first check if the value for that attribute already exists and that you don’t specify the value_id as that is an auto-increment value.

Leave a Reply

Your email address will not be published. Required fields are marked *