diff options
| author | trisusilo <tri.susilo@altama.co.id> | 2023-10-30 02:32:42 +0000 |
|---|---|---|
| committer | trisusilo <tri.susilo@altama.co.id> | 2023-10-30 02:32:42 +0000 |
| commit | 3196c41e81bce2f012e245e44beb689dcd1fc853 (patch) | |
| tree | 25f9169a48fabcdcabb4da2621f1196b840241a3 /src/pages | |
| parent | e8c414325a1e32474e740cc6e7dca8396affc5e3 (diff) | |
| parent | 0a1413aec32fddc433a34bf7d03d8681dedc266d (diff) | |
Merged in CR/UI (pull request #111)
CR/UI
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/api/shop/brands.js | 6 | ||||
| -rw-r--r-- | src/pages/api/shop/search.js | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/pages/api/shop/brands.js b/src/pages/api/shop/brands.js index e93fe2c9..2025da70 100644 --- a/src/pages/api/shop/brands.js +++ b/src/pages/api/shop/brands.js @@ -12,6 +12,11 @@ export default async function handler(req, res) { case 'level_s': params = 'level_s:prioritas' break + case 'search': + params = `name_s:${req?.query?.q}` + sort = '' + rows = 1 + break; default: params = `name_s:${req.query.params}` } @@ -20,7 +25,6 @@ export default async function handler(req, res) { process.env.SOLR_HOST + `/solr/brands/select?q=${params}&q.op=OR&indent=true&rows=${rows}&${sort}` ) - let dataBrands = responseMap(brands.data.response.docs) res.status(200).json(dataBrands) diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 883bb8df..576d028a 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -66,8 +66,9 @@ export default async function handler(req, res) { ) } - if (brand) parameter.push(`fq=manufacture_name:${brand.replace(/,/g, ' OR ')}`) - if (category) parameter.push(`fq=category_name:${category.replace(/,/g, ' OR ')}`) + if (brand) parameter.push(`fq=${brand.split(',').map(manufacturer => `manufacture_name:"${manufacturer}"`).join(" OR ")}`) + if (category) parameter.push(`fq=${category.split(',').map(cat => `category_name:"${cat}"`).join(' OR ')}`) + // if (category) parameter.push(`fq=category_name:${capitalizeFirstLetter(category.replace(/,/g, ' OR '))}`) if (stock) parameter.push(`fq=stock_total_f:{1 TO *}`) // Single fq in url params |
