Skip to content

Commit

Permalink
Merge pull request #22 from svaxy/dropdown-eav-default-method
Browse files Browse the repository at this point in the history
Add a default method for fetching dropdown eav attribute options
  • Loading branch information
Schrank committed May 23, 2016
2 parents 747aacd + a8097c6 commit d3e03fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ XML Syntax
</add>
</column>

<manufacturer>
<add>
<header>Manufacturer</header>
<type>options</type>
<index>manufacturer</index>
<options>firegento_gridcontrol/utility::getDropdownAttributeLabelOptionArray(manufacturer)</options>
</add>
</manufacturer>

<selecttest>
<add>
<header>Status Column</header>
Expand All @@ -74,4 +83,4 @@ XML Syntax
</gridname>
</grids>
</gridcontrol>
``````
``````
24 changes: 24 additions & 0 deletions src/app/code/community/FireGento/GridControl/Model/Utility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

class FireGento_GridControl_Model_Utility
{
public function getDropdownAttributeLabelOptionArray($attribute)
{
$map = array();

if (is_array($attribute)) {
$attribute = reset($attribute);
}

if ($attribute) {
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute);
$options = $attribute->getSource()->getAllOptions(false);

foreach ($options as $option) {
$map[$option['value']] = $option['label'];
}
}

return $map;
}
}

0 comments on commit d3e03fd

Please sign in to comment.