Fix search sorting

This commit is contained in:
Amanmyrat 2023-09-23 18:55:46 +05:00
parent 95be1bb321
commit 154403d06f
1 changed files with 1 additions and 10 deletions

View File

@ -77,6 +77,7 @@ class ProductRepository extends WProductRepository
{
$channel = core()->getRequestedChannelCode();
$params = request()->input();
$locale = core()->getRequestedLocaleCode();
if (config('scout.driver') == 'algolia') {
@ -138,16 +139,6 @@ class ProductRepository extends WProductRepository
}
});
/* added for api as per the documentation */
if (isset($params['name'])) {
$query->where('product_flat.name', 'like', '%' . urldecode($params['name']) . '%');
}
/* added for api as per the documentation */
if (isset($params['url_key'])) {
$query->where('product_flat.url_key', 'like', '%' . urldecode($params['url_key']) . '%');
}
# sort direction
$orderDirection = 'asc';
if (isset($params['order']) && in_array($params['order'], ['desc', 'asc'])) {