Skip to content

Commit

Permalink
Merge pull request #872 from afoucret/fix-api-error
Browse files Browse the repository at this point in the history
Fix #869 : API error when sort order or filter are missing.
  • Loading branch information
afoucret authored Apr 16, 2018
2 parents 4d176af + 4ebbdc9 commit 70a5e22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/module-elasticsuite-core/Model/Search/RequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getSortOrders(ContainerConfigurationInterface $containerConfigur
{
$sortOrders = [];

foreach ($searchCriteria->getSortOrders() as $sortOrder) {
foreach ($searchCriteria->getSortOrders() ?? [] as $sortOrder) {
$sortOrders[$sortOrder->getField()] = ['direction' => $sortOrder->getDirection()];
}

Expand All @@ -61,8 +61,8 @@ public function getFilters(ContainerConfigurationInterface $containerConfigurati
{
$filters = [];

foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
foreach ($filterGroup->getFilters() as $filter) {
foreach ($searchCriteria->getFilterGroups() ?? [] as $filterGroup) {
foreach ($filterGroup->getFilters() ?? [] as $filter) {
if ($filter->getField() != "search_term") {
$filters[$filter->getField()] = [$filter->getConditionType() => $filter->getValue()];
}
Expand Down

0 comments on commit 70a5e22

Please sign in to comment.