summaryrefslogtreecommitdiff
path: root/src-migrate/services
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-15 14:20:30 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-15 14:20:30 +0700
commit4fb570559e293d506819059ce42836562a2fb4d2 (patch)
tree4546cfa08d7be7342c80e2a1fa25a3d56dcbdeb1 /src-migrate/services
parentbbbd7ccaab3102558dc82cbd051947b0e579360c (diff)
<iman> update search product using name
Diffstat (limited to 'src-migrate/services')
-rw-r--r--src-migrate/services/product.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src-migrate/services/product.ts b/src-migrate/services/product.ts
index 2152ba26..a5039ad9 100644
--- a/src-migrate/services/product.ts
+++ b/src-migrate/services/product.ts
@@ -76,8 +76,13 @@ export const getProductSimilar = async ({
dataflashSale = dataflashSale
}
}
+
+ const regex = /\b(?![A-Z\s]+\b)[A-Za-z\s]+\b/g;
+ const matches = name?.match(regex);
+ const extractedName = matches ? matches.join(' ').trim() : '';
+ console.log("extractedName",extractedName);
const query = [
- `q=${name}`,
+ `q=${extractedName}`,
'page=1',
'orderBy=popular-weekly',
'operation=OR',