Skip to content

Commit

Permalink
Merge pull request #3399 from frank-bokdam/patch-2
Browse files Browse the repository at this point in the history
Improve sortOrder direction fallback in case of empty string
  • Loading branch information
romainruaud authored Oct 22, 2024
2 parents c2c2ce5 + b647052 commit 31e6939
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/module-elasticsuite-virtual-category/Model/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ protected function prepareProductCollection(Collection $collection) : Collection
$sortBy = $this->getSortBy() ?? 'position';
$directionFallback = $sortBy !== 'position' ? Collection::SORT_ORDER_ASC : Collection::SORT_ORDER_DESC;

$collection->setOrder($sortBy, $this->request->getParam('sort_direction', $directionFallback));
$direction = $this->request->getParam('sort_direction', $directionFallback);
if (empty($direction)) {
$direction = $directionFallback;
}
$collection->setOrder($sortBy, $direction);
$collection->addPriceData(self::DEFAULT_CUSTOMER_GROUP_ID, $this->category->getStore()->getWebsiteId());

return $collection;
Expand Down

0 comments on commit 31e6939

Please sign in to comment.