summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-10-14 09:29:14 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-10-14 09:29:14 +0700
commitf6b1aea824192572b241f94157ab3731dec6a4ea (patch)
treecd9e2cb3e7e922bfa8cc730028397e924cabdb1e
parent88d017f7f325bfcaea7d02081e2ded91b374861a (diff)
<Miqdad> fix brand solr
-rw-r--r--src/pages/api/shop/search.js41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js
index 6bf10672..8c9782cb 100644
--- a/src/pages/api/shop/search.js
+++ b/src/pages/api/shop/search.js
@@ -142,30 +142,29 @@ export default async function handler(req, res) {
if (auth.feature.onlyReadyStock) stock = true;
}
- if (brand)
- parameter.push(
- // tag filter brand
- `fq=${encodeURIComponent(
- `{!tag=brand}manufacture_name_s:(${brand
- .split(',')
- .map((manufacturer) => `"${manufacturer.replace(/"/g, '\\"')}"`)
- .join(' OR ')})`
- )}`
- );
+ if (brand) {
+ // bentuk ekspresi sama seperti versi kamu, tapi dibungkus tag brand
+ const brandExpr = brand
+ .split(',')
+ .map(
+ (manufacturer) =>
+ `manufacture_name:"${encodeURIComponent(manufacturer)}"`
+ )
+ .join(' OR ');
+ parameter.push(`fq={!tag=brand}(${brandExpr})`);
+ }
- if (category)
- parameter.push(
- // tag filter category
- `fq=${encodeURIComponent(
- `{!tag=cat}category_name:(${category
- .split(',')
- .map((cat) => `"${cat.replace(/"/g, '\\"')}"`)
- .join(' OR ')})`
- )}`
- );
+ if (category) {
+ // sama: tag kategori
+ const catExpr = category
+ .split(',')
+ .map((cat) => `category_name:"${encodeURIComponent(cat)}"`)
+ .join(' OR ');
+ parameter.push(`fq={!tag=cat}(${catExpr})`);
+ }
// if (category) parameter.push(`fq=category_name:${capitalizeFirstLetter(category.replace(/,/g, ' OR '))}`)
- if (stock) parameter.push(`fq=stock_total_f:[1 TO *]`);
+ if (stock) parameter.push(`fq=stock_total_f:(1 TO *)`);
// Single fq in url params
if (typeof fq === 'string') parameter.push(`fq=${encodeURIComponent(fq)}`);