Fix search sorting
This commit is contained in:
parent
154403d06f
commit
21bc5c56d9
|
|
@ -77,7 +77,6 @@ class ProductRepository extends WProductRepository
|
||||||
{
|
{
|
||||||
$channel = core()->getRequestedChannelCode();
|
$channel = core()->getRequestedChannelCode();
|
||||||
|
|
||||||
$params = request()->input();
|
|
||||||
$locale = core()->getRequestedLocaleCode();
|
$locale = core()->getRequestedLocaleCode();
|
||||||
|
|
||||||
if (config('scout.driver') == 'algolia') {
|
if (config('scout.driver') == 'algolia') {
|
||||||
|
|
@ -114,6 +113,8 @@ class ProductRepository extends WProductRepository
|
||||||
} else {
|
} else {
|
||||||
$results = app(ProductFlatRepository::class)->scopeQuery(function ($query) use ($term, $channel, $locale) {
|
$results = app(ProductFlatRepository::class)->scopeQuery(function ($query) use ($term, $channel, $locale) {
|
||||||
|
|
||||||
|
$params = request()->input();
|
||||||
|
|
||||||
$query = $query->distinct()
|
$query = $query->distinct()
|
||||||
->addSelect('product_flat.*')
|
->addSelect('product_flat.*')
|
||||||
->where('product_flat.channel', $channel)
|
->where('product_flat.channel', $channel)
|
||||||
|
|
@ -139,6 +140,16 @@ 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
|
# sort direction
|
||||||
$orderDirection = 'asc';
|
$orderDirection = 'asc';
|
||||||
if (isset($params['order']) && in_array($params['order'], ['desc', 'asc'])) {
|
if (isset($params['order']) && in_array($params['order'], ['desc', 'asc'])) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue