search fix
This commit is contained in:
parent
e3dfc1069b
commit
a95897d137
|
|
@ -484,15 +484,15 @@ class ProductRepository extends WProductRepository
|
|||
$options['sort'] = ['name:asc'];
|
||||
# sort direction
|
||||
|
||||
if (isset($params['order']) && in_array($params['order'], ['desc', 'asc'])) {
|
||||
$orderDirection = $params['order'];
|
||||
if (request()->has('order') && in_array(request()->get('order'), ['desc', 'asc'])) {
|
||||
$orderDirection = request()->get('order');
|
||||
} else {
|
||||
$sortOptions = $this->getDefaultSortByOption();
|
||||
|
||||
$orderDirection = ! empty($sortOptions) ? $sortOptions[1] : 'asc';
|
||||
}
|
||||
|
||||
if (isset($params['sort']) && $attribute = $this->attributeRepository->findOneByField('code', $params['sort'])) {
|
||||
if (request()->has('sort') && $attribute = $this->attributeRepository->findOneByField('code', request()->get('sort'))) {
|
||||
|
||||
if ($attribute->code === 'price') {
|
||||
$options['sort'] = ["min_price:$orderDirection"];
|
||||
|
|
|
|||
Loading…
Reference in New Issue