Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from robbieaverill/hotfix/12-swatch-order
Browse files Browse the repository at this point in the history
[#12] Fix for when there are no attribute options at all
  • Loading branch information
robbieaverill committed Jan 18, 2016
2 parents 48d1071 + cdc784c commit f0451d1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ You can use this extension module to restore to relevance ordering until the cor

## Changelog:

### 1.1.2

* Fix #12 - hot fix for empty attribute option arrays in the helper

### 1.1.1

* Fix #12 - added support for ordering swatch options
Expand Down
5 changes: 4 additions & 1 deletion app/code/local/RobbieAverill/AttributeFix/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class RobbieAverill_AttributeFix_Helper_Data extends Mage_Core_Helper_Abstract
*/
public function sortOptionValues($options)
{
if (empty($options)) {
return $options;
}
$optionIds = array_keys($options);
$sortOrder = $this->getSortOrderForAttributeOptions($optionIds);

$sortOrder = $this->getSortOrderForAttributeOptions($optionIds);
foreach ($sortOrder as $optionId => &$value) {
$value = $options[$optionId];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testShouldGetAttributeOrdersThenOrderThem($testCase, $input, $or
$mock = $this->getHelperMock('attributefix', ['getSortOrderForAttributeOptions']);

$mock
->expects($this->once())
->expects(empty($input) ? $this->any() : $this->once())
->method('getSortOrderForAttributeOptions')
->will($this->returnValue($order));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ tc_2:
2: attr2
3: attr3
4: attr4
# No options - whatever passed in should be returned
tc_3:
result: []
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@
- 1: 0
2: 0
3: 0
4: 0
4: 0
# No options at all
-
- 3
- []
- []
2 changes: 1 addition & 1 deletion app/code/local/RobbieAverill/AttributeFix/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->
<modules>
<RobbieAverill_AttributeFix>
<version>1.1.1</version>
<version>1.1.2</version>
</RobbieAverill_AttributeFix>
</modules>
<global>
Expand Down

0 comments on commit f0451d1

Please sign in to comment.