summaryrefslogtreecommitdiff
path: root/src/pages/api
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-09-03 14:01:02 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-09-03 14:01:02 +0700
commitad168bf46919b46f708625b7d2fdc56606ec9af6 (patch)
treeaeb006a210788db8bb671d716bba3cacdbd22e95 /src/pages/api
parent105ffc8cfa4d8efd51bb7654bfdd279df2a64779 (diff)
<iman> update all promo fix
Diffstat (limited to 'src/pages/api')
-rw-r--r--src/pages/api/shop/promo.js15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/pages/api/shop/promo.js b/src/pages/api/shop/promo.js
index 57635958..221a9adb 100644
--- a/src/pages/api/shop/promo.js
+++ b/src/pages/api/shop/promo.js
@@ -3,7 +3,6 @@ import axios from 'axios';
import camelcaseObjectDeep from 'camelcase-object-deep';
export default async function handler(req, res) {
- console.log("req_iman",req)
const {
q = '*',
page = 1,
@@ -11,7 +10,7 @@ export default async function handler(req, res) {
category = '',
priceFrom = 0,
priceTo = 0,
- orderBy = '',
+ orderBy = 'if(exists(sequence_i),0,1) asc, sequence_i asc,',
operation = 'AND',
fq = '',
limit = 30,
@@ -19,7 +18,7 @@ export default async function handler(req, res) {
let { stock = '' } = req.query;
- let paramOrderBy = '';
+ let paramOrderBy = 'if(exists(sequence_i),0,1) asc, sequence_i asc,';
switch (orderBy) {
case 'price-asc':
paramOrderBy += 'price_tier1_v2_f ASC';
@@ -60,7 +59,7 @@ export default async function handler(req, res) {
`start=${parseInt(offset)}`,
`rows=${limit}`,
`sort=${paramOrderBy}`,
- // `fq=-publish_b:false, product_rating_f:[8 TO *], price_tier1_v2_f:[1 TO *]`,
+ `fq=product_ids:[* TO *]`,
];
if (priceFrom > 0 || priceTo > 0) {
@@ -83,7 +82,7 @@ export default async function handler(req, res) {
.split(',')
.map(
(manufacturer) =>
- `manufacture_name:"${encodeURIComponent(manufacturer)}"`
+ `manufacture_name_s:"${encodeURIComponent(manufacturer)}"`
)
.join(' OR ')}`
);
@@ -102,19 +101,14 @@ export default async function handler(req, res) {
// Multi fq in url params
if (Array.isArray(fq))
parameter = parameter.concat(fq.map((val) => `fq=${val}`));
-
- console.log("parameter",parameter)
let result = await axios(
process.env.SOLR_HOST + '/solr/promotion_program_lines/select?' + parameter.join('&')
);
- console.log("result",result.data)
try {
- console.log("result.data.response.docs",result.data.response.docs)
result.data.response.products = promoMappingSolr(
result.data.response.docs
);
- console.log("result.data.response.products",result.data.response.products)
result.data.responseHeader.params.start = parseInt(
result.data.responseHeader.params.start
@@ -123,7 +117,6 @@ export default async function handler(req, res) {
result.data.responseHeader.params.rows
);
delete result.data.response.docs;
- console.log("result.data",result.data)
// result.data = camelcaseObjectDeep(result.data);
result.data = result.data;
res.status(200).json(result.data);