Magento: Alle Produkt-Attribute und deren Optionen einer Collection ausgeben
Mit dem folgenden Code könnt ihr in Magento eine Liste aller Attribute und deren Optionen ausgeben.
require_once $_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php';
umask(0);
Mage::app();
$product = Mage::getModel('catalog/product');
$collection = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId());
echo "<pre>\n";
foreach ($collection as $attribute) {
echo $attribute['attribute_code'] . "\n";
$collection = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', $attribute['attribute_code']);
$_attribute = $collection->getFirstItem()->setEntity($product->getResource());
$attribute_options = $_attribute->getSource()->getAllOptions(false);
if ($attribute_options) {
foreach ($attribute_options as $option) {
if ($option['label']) {
echo "\t" . $option['label'] . "\n";
}
}
}
}
echo "</pre>\n";

