Add search sorting
This commit is contained in:
parent
a7dd03173d
commit
2ff8ed6c29
|
|
@ -123,6 +123,24 @@ class ProductRepository extends WProductRepository
|
||||||
->leftJoin('marketplace_sellers', 'marketplace_sellers.id', '=', 'marketplace_products.marketplace_seller_id')
|
->leftJoin('marketplace_sellers', 'marketplace_sellers.id', '=', 'marketplace_products.marketplace_seller_id')
|
||||||
->addSelect('marketplace_sellers.shop_title');
|
->addSelect('marketplace_sellers.shop_title');
|
||||||
|
|
||||||
|
# sort direction
|
||||||
|
$orderDirection = 'asc';
|
||||||
|
if (isset($params['order']) && in_array($params['order'], ['desc', 'asc'])) {
|
||||||
|
$orderDirection = $params['order'];
|
||||||
|
} else {
|
||||||
|
$sortOptions = $this->getDefaultSortByOption();
|
||||||
|
$orderDirection = ! empty($sortOptions) ? $sortOptions[1] : 'asc';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['sort'])) {
|
||||||
|
$this->checkSortAttributeAndGenerateQuery($query, $params['sort'], $orderDirection);
|
||||||
|
} else {
|
||||||
|
$sortOptions = $this->getDefaultSortByOption();
|
||||||
|
if (! empty($sortOptions)) {
|
||||||
|
$this->checkSortAttributeAndGenerateQuery($query, $sortOptions[0], $orderDirection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {
|
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {
|
||||||
$query = $this->checkOutOfStockItem($query);
|
$query = $this->checkOutOfStockItem($query);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue