Skip to content

Instantly share code, notes, and snippets.

@simbus82
Last active May 11, 2017 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simbus82/8b32c5e0433e93eb6f17624bcd36e31a to your computer and use it in GitHub Desktop.
Save simbus82/8b32c5e0433e93eb6f17624bcd36e31a to your computer and use it in GitHub Desktop.
PHP to export Magento Attributes
<?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() . ')' . ",";
echo '"';
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
if(empty($option['label'])) continue;
echo $option['label'].',';
}
echo '"'."\r\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment