-
Notifications
You must be signed in to change notification settings - Fork 7
/
attrset-list.php
executable file
·36 lines (34 loc) · 1.54 KB
/
attrset-list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/php
<?php
require_once 'lib/init.php';
echo "List all product attribute sets\n";
$entityType = Mage::getModel('catalog/product')->getResource()->getEntityType();
$collection = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter($entityType->getId());
printf("%3s %-30s %s\n", "ID", "NAME", "DEFAULT GROUP");
foreach ($collection as $attributeSet) {
$defaultGroupId = $attributeSet->getDefaultGroupId();
$defaultGroup = Mage::getModel('eav/entity_attribute_group')->load($attributeSet->getDefaultGroupId());
printf("%3d %-30s %3d %-20s\n", $attributeSet->getId(), $attributeSet->getAttributeSetName(),
$defaultGroupId, $defaultGroup->getAttributeGroupName());
/** @var $groupCollection Mage_Eav_Model_Resource_Entity_Attribute_Group_Collection */
$groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
->setAttributeSetFilter($attributeSet->getId())
->setSortOrder()
->load();
foreach ($groupCollection as $group) {
/* @var $group Mage_Eav_Model_Entity_Attribute_Group */
$attrs = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeGroupFilter($group->getId())
->addVisibleFilter()
->checkConfigurableProducts();
$attrCodes = array();
foreach ($attrs as $attr) {
$attrCodes[] = $attr->getAttributeCode() .'/'. $attr->getSortOrder();
}
printf(" %-20s: %s\n", $group->getAttributeGroupName(), join(' ', $attrCodes));
// if ($defaultGroupId == 0 or $group->getIsDefault()) {
// $defaultGroupId = $group->getId();
// }
}
}