diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-24 09:29:31 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-24 09:29:31 +0700 |
| commit | e9f3435ceb5d85e4926f26c3a893b96edb898918 (patch) | |
| tree | 0a2ee9910ffec53bc2ef17a5e44f012066223448 /src/pages/api | |
| parent | e17210013af6aa12e1641cd9055d892e16409e1e (diff) | |
<iman> update ready stock search
Diffstat (limited to 'src/pages/api')
| -rw-r--r-- | src/pages/api/shop/search.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 6f98efcb..eadccede 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -18,6 +18,8 @@ export default async function handler(req, res) { let { stock = '' } = req.query; + let isStock = false + let paramOrderBy = ''; switch (orderBy) { case 'price-asc': @@ -33,6 +35,7 @@ export default async function handler(req, res) { paramOrderBy += 'search_rank_weekly_i DESC'; break; case 'stock': + isStock = true paramOrderBy += 'product_rating_f DESC, stock_total_f DESC'; break; case 'flashsale-price-asc': @@ -94,7 +97,7 @@ export default async function handler(req, res) { .join(' OR ')}` ); // if (category) parameter.push(`fq=category_name:${capitalizeFirstLetter(category.replace(/,/g, ' OR '))}`) - if (stock) parameter.push(`fq=stock_total_f:{1 TO *}`); + if (stock || isStock) parameter.push(`fq=stock_total_f:[0.1 TO *]`); // Single fq in url params if (typeof fq === 'string') parameter.push(`fq=${fq}`); |
