Skip to content

Commit

Permalink
Merge pull request #87 from oc-shopaholic/develop
Browse files Browse the repository at this point in the history
Release version 1.29.0
  • Loading branch information
kharanenka authored Mar 12, 2020
2 parents 79fe8ec + 9eb64a6 commit c853ce8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions classes/collection/ElementCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,17 @@ public function random($iCount = 1)
}

$obThis = $this->copy();
shuffle($obThis->arElementIDList);

return $obThis->take($iCount);
$arElementIDList = $obThis->getIDList();
$arKeyList = array_rand($arElementIDList, $iCount);
if (!is_array($arKeyList)) {
$arKeyList = [$arKeyList];
}

$arKeyList = array_combine($arKeyList, $arKeyList);
$arElementIDList = array_intersect_key($arElementIDList, $arKeyList);

return $obThis->intersect($arElementIDList)->all();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@
1.28.0:
- 'Added dimension fields to lang files'
1.28.1:
- 'Added passing $this param to get[FieldName]Attribute() method in ElementItem class. It is recommended to use parameter from callback function in the dynamic methods get[FieldName]Attribute in ElementItem class.'
- 'Added passing $this param to get[FieldName]Attribute() method in ElementItem class. It is recommended to use parameter from callback function in the dynamic methods get[FieldName]Attribute in ElementItem class.'
1.29.0:
- 'Improved speed of random method in ElementCollection class.'

0 comments on commit c853ce8

Please sign in to comment.