Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Created December 10, 2013 15:31
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save peterjaap/7892509 to your computer and use it in GitHub Desktop.
Save peterjaap/7892509 to your computer and use it in GitHub Desktop.
Export Magento attributes and their options to a human-readable CSV file.
<?php
chdir(dirname(__FILE__));
require_once '../app/Mage.php';
Mage::app();
umask(0);
$productModel = Mage::getModel('Mage_Catalog_Model_Product');
$categoryModel = Mage::getModel('Mage_Catalog_Model_Category');
$resource = Mage::getModel('core/resource');
$db = $resource->getConnection('core_write');
$attributes = Mage::getSingleton('eav/config')
->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
foreach($attributes as $attribute) {
#if(!$attribute->getIsUserDefined()) continue;
if($attribute->getEntityTypeId() != 4) continue;
if($attribute->getFrontendInput() != 'select' && $attribute->getFrontendInput() != 'multiselect') continue;
echo $attribute->getFrontendLabel(). ' (' . $attribute->getAttributeCode() . ')' . "\n";
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
if(empty($option['label'])) continue;
echo "," . $option['label']."\n";
}
echo "================,=================\n";
}
@nhartman7
Copy link

Does this work with Magento v1.9? I made a PHP file with it and just received a 500 ERROR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment