From cd51b64b48b0c898c6ff901c1bfa23c70cd9cf1a Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 16:12:21 +0700 Subject: sementara --- src/pages/api/shop/product-detail.js | 30 +++++++++++++++++----------- src/pages/api/shop/search.js | 2 +- src/pages/google_merchant/products/[page].js | 4 +++- src/pages/google_merchant/products/index.js | 4 +++- src/pages/sitemap/products/[page].js | 6 +++--- 5 files changed, 28 insertions(+), 18 deletions(-) (limited to 'src/pages') diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index faa96028..504f9dd6 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -1,26 +1,32 @@ -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 productTemplate = await axios( - process.env.SOLR_HOST + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` - ) + process.env.SOLR_HOST + + `/solr/product/select?q=id:${req.query.id}&q.op=OR&indent=true` + ); let productVariants = await axios( process.env.SOLR_HOST + - `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100&fq=-publish_b:false AND price_tier1_v2_f:[1 TO *]` - ) - let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth - let result = productMappingSolr(productTemplate.data.response.docs, auth || false) + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100` + // `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100&fq=-publish_b:false AND price_tier1_v2_f:[1 TO *]` + ); + let auth = + req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth; + let result = productMappingSolr( + productTemplate.data.response.docs, + auth || false + ); result[0].variants = variantsMappingSolr( productTemplate.data.response.docs[0], productVariants.data.response.docs, auth || false - ) - res.status(200).json(result) + ); + 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' }); } } diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index 8c9782cb..a3e1b3a3 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -83,7 +83,7 @@ export default async function handler(req, res) { : `${checkQ.length}`; const filterQueries = [ - '-publish_b:false', + // '-publish_b:false', 'product_rating_f:[8 TO *]', 'price_tier1_v2_f:[1 TO *]', ]; diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 161b6aec..2a53f7c0 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -18,7 +18,9 @@ export async function getServerSideProps({ res, query }) { page: page.replace('.xml', ''), priceFrom: 1, orderBy: 'popular', - fq: ['image_s:["" TO *] AND publish_b:true'], + fq: ['image_s:["" TO *] AND publish_b:true AND price_tier1_v2_f:[1 TO *]'], + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await variantSearchApi({ query: _.toQuery(queries) }); diff --git a/src/pages/google_merchant/products/index.js b/src/pages/google_merchant/products/index.js index b6c7bfef..d6ef413a 100644 --- a/src/pages/google_merchant/products/index.js +++ b/src/pages/google_merchant/products/index.js @@ -8,7 +8,9 @@ export async function getServerSideProps() { const queries = { limit: 1, priceFrom: 1, - fq: 'image_s:["" TO *] AND publish_b:true', + fq: 'image_s:["" TO *] AND publish_b:true AND price_tier1_v2_f:[1 TO *]', + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await variantSearchApi({ query: _.toQuery(queries) }); const { numFound } = products.response; diff --git a/src/pages/sitemap/products/[page].js b/src/pages/sitemap/products/[page].js index 421c08e3..ebb6aef7 100644 --- a/src/pages/sitemap/products/[page].js +++ b/src/pages/sitemap/products/[page].js @@ -10,9 +10,9 @@ export async function getServerSideProps({ query, res }) { const queries = { limit, page: page.replace('.xml', ''), - '-publish_b': false, - product_rating_f: '[8 TO *]', - price_tier1_v2_f: '[1 TO *]', + // '-publish_b': false, + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await productSearchApi({ query: _.toQuery(queries) }); const sitemap = create('urlset', { encoding: 'utf-8' }).att( -- cgit v1.2.3 From 31a0644d72475279b16cd646ab5d2f60facc0b24 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 18:45:54 +0700 Subject: balikin --- src/pages/api/shop/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pages') diff --git a/src/pages/api/shop/search.js b/src/pages/api/shop/search.js index a3e1b3a3..8c9782cb 100644 --- a/src/pages/api/shop/search.js +++ b/src/pages/api/shop/search.js @@ -83,7 +83,7 @@ export default async function handler(req, res) { : `${checkQ.length}`; const filterQueries = [ - // '-publish_b:false', + '-publish_b:false', 'product_rating_f:[8 TO *]', 'price_tier1_v2_f:[1 TO *]', ]; -- cgit v1.2.3 From a19ab70ca8f3f20c845ddeed0a5281d2abc29f03 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 15:48:26 +0700 Subject: update robots & last mod --- src/pages/sitemap/blogs.xml.js | 4 ++-- src/pages/sitemap/brands.xml.js | 4 ++-- src/pages/sitemap/categories-brand.xml.js | 4 ++-- src/pages/sitemap/categories-brand/[page].js | 4 ++-- src/pages/sitemap/categories.xml.js | 4 ++-- src/pages/sitemap/products.xml.js | 4 ++-- src/pages/sitemap/products/[page].js | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/pages') diff --git a/src/pages/sitemap/blogs.xml.js b/src/pages/sitemap/blogs.xml.js index 628dc710..3b6969b8 100644 --- a/src/pages/sitemap/blogs.xml.js +++ b/src/pages/sitemap/blogs.xml.js @@ -10,8 +10,8 @@ export async function getServerSideProps({ res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; blogs.blogs.forEach((blog) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, blog.title, blog.id)); diff --git a/src/pages/sitemap/brands.xml.js b/src/pages/sitemap/brands.xml.js index c2199d85..3c7f1ade 100644 --- a/src/pages/sitemap/brands.xml.js +++ b/src/pages/sitemap/brands.xml.js @@ -10,8 +10,8 @@ export async function getServerSideProps({ res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; brands.manufactures.forEach((brand) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, brand.name, brand.id)); diff --git a/src/pages/sitemap/categories-brand.xml.js b/src/pages/sitemap/categories-brand.xml.js index faf67b9f..f3f2b33f 100644 --- a/src/pages/sitemap/categories-brand.xml.js +++ b/src/pages/sitemap/categories-brand.xml.js @@ -16,8 +16,8 @@ export async function getServerSideProps({ res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; pages.forEach((page) => { const sitemap = sitemapIndex.ele('sitemap'); sitemap.ele('loc', `${baseUrl}/${page}.xml`); diff --git a/src/pages/sitemap/categories-brand/[page].js b/src/pages/sitemap/categories-brand/[page].js index 4d28ab04..3b81aaea 100644 --- a/src/pages/sitemap/categories-brand/[page].js +++ b/src/pages/sitemap/categories-brand/[page].js @@ -22,8 +22,8 @@ export async function getServerSideProps({ query, res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; categories.data.response.docs.forEach((product) => { const url = sitemap.ele('url'); const loc = product.url_s; diff --git a/src/pages/sitemap/categories.xml.js b/src/pages/sitemap/categories.xml.js index 357a2072..61fe42d1 100644 --- a/src/pages/sitemap/categories.xml.js +++ b/src/pages/sitemap/categories.xml.js @@ -28,8 +28,8 @@ export async function getServerSideProps({ res }) { function addUrlToSitemap(sitemap, name, id) { const baseUrl = process.env.SELF_HOST + '/shop/category/'; - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, name, id)); url.ele('lastmod', date); diff --git a/src/pages/sitemap/products.xml.js b/src/pages/sitemap/products.xml.js index 0269ec59..221a024a 100644 --- a/src/pages/sitemap/products.xml.js +++ b/src/pages/sitemap/products.xml.js @@ -14,8 +14,8 @@ export async function getServerSideProps({ res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; pages.forEach((page) => { const sitemap = sitemapIndex.ele('sitemap'); sitemap.ele('loc', `${baseUrl}/${page}.xml`); diff --git a/src/pages/sitemap/products/[page].js b/src/pages/sitemap/products/[page].js index ebb6aef7..f9fba72b 100644 --- a/src/pages/sitemap/products/[page].js +++ b/src/pages/sitemap/products/[page].js @@ -20,8 +20,8 @@ export async function getServerSideProps({ query, res }) { 'http://www.sitemaps.org/schemas/sitemap/0.9' ); - // const date = new Date() - const date = '2025-10-30'; + const date = new Date(); + // const date = '2025-10-30'; products.response.products.forEach((product) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, product.name, product.id)); -- cgit v1.2.3 From fba96afd46d37e9cac4f480dac7c6a8fba36ae9a Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 16:28:01 +0700 Subject: fix xml date --- src/pages/sitemap/blogs.xml.js | 2 +- src/pages/sitemap/brands.xml.js | 2 +- src/pages/sitemap/categories-brand.xml.js | 2 +- src/pages/sitemap/categories-brand/[page].js | 2 +- src/pages/sitemap/categories.xml.js | 2 +- src/pages/sitemap/products.xml.js | 2 +- src/pages/sitemap/products/[page].js | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/pages') diff --git a/src/pages/sitemap/blogs.xml.js b/src/pages/sitemap/blogs.xml.js index 3b6969b8..1125ad1c 100644 --- a/src/pages/sitemap/blogs.xml.js +++ b/src/pages/sitemap/blogs.xml.js @@ -15,7 +15,7 @@ export async function getServerSideProps({ res }) { blogs.blogs.forEach((blog) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, blog.title, blog.id)); - url.ele('lastmod', date); + url.ele('lastmod', date.toISOString().slice(0, 10)); url.ele('changefreq', 'weekly'); url.ele('priority', '0.6'); }); diff --git a/src/pages/sitemap/brands.xml.js b/src/pages/sitemap/brands.xml.js index 3c7f1ade..dc92419c 100644 --- a/src/pages/sitemap/brands.xml.js +++ b/src/pages/sitemap/brands.xml.js @@ -15,7 +15,7 @@ export async function getServerSideProps({ res }) { brands.manufactures.forEach((brand) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, brand.name, brand.id)); - url.ele('lastmod', date); + url.ele('lastmod', date.toISOString().slice(0, 10)); url.ele('changefreq', 'daily'); url.ele('priority', '1.0'); }); diff --git a/src/pages/sitemap/categories-brand.xml.js b/src/pages/sitemap/categories-brand.xml.js index f3f2b33f..8dfd3a32 100644 --- a/src/pages/sitemap/categories-brand.xml.js +++ b/src/pages/sitemap/categories-brand.xml.js @@ -21,7 +21,7 @@ export async function getServerSideProps({ res }) { pages.forEach((page) => { const sitemap = sitemapIndex.ele('sitemap'); sitemap.ele('loc', `${baseUrl}/${page}.xml`); - sitemap.ele('lastmod', date); + sitemap.ele('lastmod', date.toISOString().slice(0, 10)); }); res.setHeader('Content-Type', 'text/xml'); diff --git a/src/pages/sitemap/categories-brand/[page].js b/src/pages/sitemap/categories-brand/[page].js index 3b81aaea..e7f264ee 100644 --- a/src/pages/sitemap/categories-brand/[page].js +++ b/src/pages/sitemap/categories-brand/[page].js @@ -28,7 +28,7 @@ export async function getServerSideProps({ query, res }) { const url = sitemap.ele('url'); const loc = product.url_s; url.ele('loc', loc); - url.ele('lastmod', date); + url.ele('lastmod', date.toISOString().slice(0, 10)); url.ele('changefreq', 'daily'); url.ele('priority', '0.8'); }); diff --git a/src/pages/sitemap/categories.xml.js b/src/pages/sitemap/categories.xml.js index 61fe42d1..18c8a8f3 100644 --- a/src/pages/sitemap/categories.xml.js +++ b/src/pages/sitemap/categories.xml.js @@ -32,7 +32,7 @@ function addUrlToSitemap(sitemap, name, id) { // const date = '2025-10-30'; const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, name, id)); - url.ele('lastmod', date); + url.ele('lastmod', date.toISOString().slice(0, 10)); url.ele('changefreq', 'weekly'); url.ele('priority', '0.6'); } diff --git a/src/pages/sitemap/products.xml.js b/src/pages/sitemap/products.xml.js index 221a024a..5ed6b759 100644 --- a/src/pages/sitemap/products.xml.js +++ b/src/pages/sitemap/products.xml.js @@ -19,7 +19,7 @@ export async function getServerSideProps({ res }) { pages.forEach((page) => { const sitemap = sitemapIndex.ele('sitemap'); sitemap.ele('loc', `${baseUrl}/${page}.xml`); - sitemap.ele('lastmod', date); + sitemap.ele('lastmod', date.toISOString().slice(0, 10)); }); res.setHeader('Content-Type', 'text/xml'); diff --git a/src/pages/sitemap/products/[page].js b/src/pages/sitemap/products/[page].js index f9fba72b..316ad33d 100644 --- a/src/pages/sitemap/products/[page].js +++ b/src/pages/sitemap/products/[page].js @@ -10,9 +10,9 @@ export async function getServerSideProps({ query, res }) { const queries = { limit, page: page.replace('.xml', ''), - // '-publish_b': false, - // product_rating_f: '[8 TO *]', - // price_tier1_v2_f: '[1 TO *]', + '-publish_b': false, + product_rating_f: '[8 TO *]', + price_tier1_v2_f: '[1 TO *]', }; const products = await productSearchApi({ query: _.toQuery(queries) }); const sitemap = create('urlset', { encoding: 'utf-8' }).att( @@ -25,7 +25,7 @@ export async function getServerSideProps({ query, res }) { products.response.products.forEach((product) => { const url = sitemap.ele('url'); url.ele('loc', createSlug(baseUrl, product.name, product.id)); - url.ele('lastmod', date); + url.ele('lastmod', date.toISOString().slice(0, 10)); url.ele('changefreq', 'daily'); url.ele('priority', '0.8'); }); -- cgit v1.2.3 From d925332714b809c4ec60aea9eeb902a2ea2ad7f4 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 16:29:09 +0700 Subject: remove query in product page sitemap --- src/pages/sitemap/products/[page].js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pages') diff --git a/src/pages/sitemap/products/[page].js b/src/pages/sitemap/products/[page].js index 316ad33d..3603d64c 100644 --- a/src/pages/sitemap/products/[page].js +++ b/src/pages/sitemap/products/[page].js @@ -10,9 +10,9 @@ export async function getServerSideProps({ query, res }) { const queries = { limit, page: page.replace('.xml', ''), - '-publish_b': false, - product_rating_f: '[8 TO *]', - price_tier1_v2_f: '[1 TO *]', + // '-publish_b': false, + // product_rating_f: '[8 TO *]', + // price_tier1_v2_f: '[1 TO *]', }; const products = await productSearchApi({ query: _.toQuery(queries) }); const sitemap = create('urlset', { encoding: 'utf-8' }).att( -- cgit v1.2.3 From 48c1110541a30bb33726a6f46737615b98f1d9c5 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 17:13:53 +0700 Subject: Fix eror --- src/pages/shop/product/variant/[slug].jsx | 46 +++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'src/pages') diff --git a/src/pages/shop/product/variant/[slug].jsx b/src/pages/shop/product/variant/[slug].jsx index 2c0dd64b..32c00a35 100644 --- a/src/pages/shop/product/variant/[slug].jsx +++ b/src/pages/shop/product/variant/[slug].jsx @@ -25,23 +25,39 @@ export async function getServerSideProps(context) { const tier = auth.pricelist ? auth.pricelist : false; const authToken = auth?.token || ''; - let response = await axios( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/variant-detail?id=` + - getIdFromSlug(slug) + - '&auth=' + - tier - ); - let product = response.data; + try { + const response = await axios( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/variant-detail?id=` + + getIdFromSlug(slug) + + '&auth=' + + tier + ); - if (product?.length == 1) { - product = product[0]; - } else { - product = null; - } + let product = response.data; - return { - props: { product }, - }; + if (product?.length == 1) { + product = product[0]; + } else { + product = null; + } + + return { + props: { product }, + }; + } catch (error) { + // kalau status 500 → tampilkan halaman 404 + if (error.response && error.response.status === 500) { + return { notFound: true }; + } + + // kalau 404 dari API juga langsung 404 + if (error.response && error.response.status === 404) { + return { notFound: true }; + } + + // kalau error lain, lempar agar bisa dilihat di console log server + throw error; + } } export default function ProductDetail({ product }) { -- cgit v1.2.3