Skip to content

Commit d3e03fd

Browse files
committed
Merge pull request #22 from svaxy/dropdown-eav-default-method
Add a default method for fetching dropdown eav attribute options
2 parents 747aacd + a8097c6 commit d3e03fd

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ XML Syntax
5252
</add>
5353
</column>
5454

55+
<manufacturer>
56+
<add>
57+
<header>Manufacturer</header>
58+
<type>options</type>
59+
<index>manufacturer</index>
60+
<options>firegento_gridcontrol/utility::getDropdownAttributeLabelOptionArray(manufacturer)</options>
61+
</add>
62+
</manufacturer>
63+
5564
<selecttest>
5665
<add>
5766
<header>Status Column</header>
@@ -74,4 +83,4 @@ XML Syntax
7483
</gridname>
7584
</grids>
7685
</gridcontrol>
77-
``````
86+
``````
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
class FireGento_GridControl_Model_Utility
4+
{
5+
public function getDropdownAttributeLabelOptionArray($attribute)
6+
{
7+
$map = array();
8+
9+
if (is_array($attribute)) {
10+
$attribute = reset($attribute);
11+
}
12+
13+
if ($attribute) {
14+
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute);
15+
$options = $attribute->getSource()->getAllOptions(false);
16+
17+
foreach ($options as $option) {
18+
$map[$option['value']] = $option['label'];
19+
}
20+
}
21+
22+
return $map;
23+
}
24+
}

0 commit comments

Comments
 (0)