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