Skip to content

Commit

Permalink
Merge pull request #736 from Leone/fix_missing-adminSortIndex-key
Browse files Browse the repository at this point in the history
Check if adminSoertIndex key exists
  • Loading branch information
afoucret authored Feb 13, 2018
2 parents 6ba08bd + 28b8a48 commit a1fd0e3
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/module-elasticsuite-catalog/Model/Layer/Filter/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,30 @@ private function addOptionsData(array $items)
}
}

usort($items, function ($item1, $item2) {
return $item1['adminSortIndex'] <= $item2['adminSortIndex'] ? -1 : 1;
});
$items = $this->sortOptionsData($items);
}

return $items;
}

/**
* Sort items by adminSortIndex key.
*
* @param array $items to be sorted.
*
* @return array
*/
private function sortOptionsData(array $items)
{

usort($items, function ($item1, $item2) {
if (!isset($item1['adminSortIndex']) or !isset($item2['adminSortIndex'])) {
return 0;
}

return $item1['adminSortIndex'] <= $item2['adminSortIndex'] ? -1 : 1;
});

return $items;
}
}

0 comments on commit a1fd0e3

Please sign in to comment.