From f0d03727f69a84daff484ea9a7944d9c29daa5c3 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Thu, 24 Oct 2024 15:02:04 +0700 Subject: done page category brand --- src/pages/api/shop/search.js | 9 ++++++--- src/pages/api/shop/url-category_brand.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/pages/api/shop/url-category_brand.js (limited to 'src/pages/api') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 49a5fe69..bc1c014b 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -88,7 +88,10 @@ export default async function handler(req, res) { 'price_tier1_v2_f:[1 TO *]', ]; - const fq_ = filterQueries.join('AND '); + if(fq){ + filterQueries.push(fq); + } + const fq_ = filterQueries.join(' AND '); let offset = (page - 1) * limit; let parameter = [ @@ -106,7 +109,7 @@ export default async function handler(req, res) { : formattedQuery }`, `defType=edismax`, - 'qf=name_s description_clean_t category_name manufacture_name_s variants_code_t variants_name_t category_id_ids default_code_s', + 'qf=name_s description_clean_t category_name manufacture_name_s variants_code_t variants_name_t category_id_ids default_code_s manufacture_id_i category_id_i ', `start=${parseInt(offset)}`, `rows=${limit}`, `sort=${paramOrderBy}`, @@ -149,7 +152,7 @@ export default async function handler(req, res) { if (stock) parameter.push(`fq=stock_total_f:{1 TO *}`); // Single fq in url params - if (typeof fq === 'string') parameter.push(`fq=${encodeURIComponent(fq)}`); + // if (typeof fq === 'string') parameter.push(`fq=${encodeURIComponent(fq)}`); // Multi fq in url params if (Array.isArray(fq)) parameter = parameter.concat( diff --git a/src/pages/api/shop/url-category_brand.js b/src/pages/api/shop/url-category_brand.js new file mode 100644 index 00000000..cfcc7d73 --- /dev/null +++ b/src/pages/api/shop/url-category_brand.js @@ -0,0 +1,17 @@ +import axios from 'axios'; + +export default async function handler(req, res) { + const { url = '' } = req.query; + + const params = [`q.op=AND`, `q=url_s:"${url}"`, `indent=true`]; + try { + let result = await axios( + process.env.SOLR_HOST + + `/solr/url_category_brand/select?` + + params.join('&') + ); + res.status(200).json(result.data); + } catch (error) { + res.status(500).json({ error: 'Internal Server Error' }); + } +} -- cgit v1.2.3 From bb2fc00e1f399be919d7b777dd0ae17edd6b2a2e Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 25 Oct 2024 10:04:34 +0700 Subject: sitemap categories brand --- src/pages/api/shop/url-category_brand.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/pages/api') diff --git a/src/pages/api/shop/url-category_brand.js b/src/pages/api/shop/url-category_brand.js index cfcc7d73..160aa166 100644 --- a/src/pages/api/shop/url-category_brand.js +++ b/src/pages/api/shop/url-category_brand.js @@ -1,9 +1,12 @@ import axios from 'axios'; export default async function handler(req, res) { - const { url = '' } = req.query; + const { url = '', page = 1, limit = 30 } = req.query; + + let offset = (page - 1) * limit; - const params = [`q.op=AND`, `q=url_s:"${url}"`, `indent=true`]; + const params = [`q.op=AND`, `q=${url ? `"${url}"` : '*'}`, `indent=true`, `rows=${limit}`, `start=${offset}`]; + try { let result = await axios( process.env.SOLR_HOST + -- cgit v1.2.3 From 2d30aea4e9d225298594ee92f474a38225b91206 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 28 Oct 2024 12:07:09 +0700 Subject: update informasi product varian --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pages/api') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index bc1c014b..ace281f7 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -88,7 +88,7 @@ export default async function handler(req, res) { 'price_tier1_v2_f:[1 TO *]', ]; - if(fq){ + if (fq && source != 'similar') { filterQueries.push(fq); } const fq_ = filterQueries.join(' AND '); -- cgit v1.2.3 From ccc224e8a6261e40e2ea1db08e21a49d280fd1c4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 7 Nov 2024 15:23:42 +0700 Subject: update fetch data logic --- src/pages/api/shop/variant-detail.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/pages/api') diff --git a/src/pages/api/shop/variant-detail.js b/src/pages/api/shop/variant-detail.js index 08ce75b8..af3525b3 100644 --- a/src/pages/api/shop/variant-detail.js +++ b/src/pages/api/shop/variant-detail.js @@ -1,21 +1,28 @@ -import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping' -import axios from 'axios' +import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping'; +import axios from 'axios'; export default async function handler(req, res) { try { let productVariants = await axios( process.env.SOLR_HOST + `/solr/variants/select?q=id:${req.query.id}&q.op=OR&indent=true` - ) - let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth + ); + let template_id = productVariants.data.response.docs[0].template_id_i; + let auth = + req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth; let productTemplate = await axios( - process.env.SOLR_HOST + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` - ) - let result = variantsMappingSolr(productTemplate.data.response.docs, productVariants.data.response.docs, auth || false) - - res.status(200).json(result) + process.env.SOLR_HOST + + `/solr/product/select?q=id:${template_id}&q.op=OR&indent=true` + ); + let result = variantsMappingSolr( + productTemplate.data.response.docs, + productVariants.data.response.docs, + auth || false + ); + + res.status(200).json(result); } catch (error) { - console.error('Error fetching data from Solr:', error) - res.status(500).json({ error: 'Internal Server Error' }) + console.error('Error fetching data from Solr:', error); + res.status(500).json({ error: 'Internal Server Error' }); } -} \ No newline at end of file +} -- cgit v1.2.3