From d20adeb6a5f6e153e2d1cfc8c8c77f4cceb743e8 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Tue, 31 Dec 2024 09:53:27 +0700 Subject: ppn 12% --- src/pages/google_merchant/products/[page].js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/pages/google_merchant') diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 0c2cf3c5..8395f839 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -6,6 +6,7 @@ import _ from 'lodash-contrib'; import { create } from 'xmlbuilder'; export async function getServerSideProps({ res, query }) { + const PPN = process.env.NEXT_PUBLIC_PPN const titleContent = 'Indoteknik.com: B2B Industrial Supply & Solution'; const descriptionContent = 'Temukan pilihan produk B2B Industri & Alat Teknik untuk Perusahaan, UMKM & Pemerintah dengan lengkap, mudah dan transparan.'; @@ -77,7 +78,7 @@ export async function getServerSideProps({ res, query }) { 'g:availability': { '#text': availability }, 'g:brand': { '#text': product.manufacture?.name || '' }, 'g:price': { - '#text': `${Math.round(product.lowestPrice.price * 1.11)} IDR`, + '#text': `${Math.round(product.lowestPrice.price * PPN)} IDR`, }, }; @@ -93,7 +94,7 @@ export async function getServerSideProps({ res, query }) { if (product.lowestPrice.discountPercentage > 0) { item['g:sale_price'] = { - '#text': `${Math.round(product.lowestPrice.priceDiscount * 1.11)} IDR`, + '#text': `${Math.round(product.lowestPrice.priceDiscount * PPN)} IDR`, }; } productItems.push(item); -- cgit v1.2.3 From 389382046d804053d8e5c6de13d7d0b197175022 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Sat, 18 Jan 2025 10:49:49 +0700 Subject: update google merchant --- src/pages/google_merchant/products/[page].js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/pages/google_merchant') diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 8395f839..ae3348cb 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -80,6 +80,7 @@ export async function getServerSideProps({ res, query }) { 'g:price': { '#text': `${Math.round(product.lowestPrice.price * PPN)} IDR`, }, + 'g:custom_label_3': { '#text': product.categories[0]?.name || 'Tidak Ada Kategori' }, }; if (product.stockTotal == 0) { -- cgit v1.2.3 From 6d9c1067b6e857eb95f12864cc88117350ae6cfb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 20 Jan 2025 15:23:52 +0700 Subject: ubah tag category --- src/pages/google_merchant/products/[page].js | 33 +++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/pages/google_merchant') diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index ae3348cb..8dd28a39 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -6,7 +6,7 @@ import _ from 'lodash-contrib'; import { create } from 'xmlbuilder'; export async function getServerSideProps({ res, query }) { - const PPN = process.env.NEXT_PUBLIC_PPN + const PPN = process.env.NEXT_PUBLIC_PPN; const titleContent = 'Indoteknik.com: B2B Industrial Supply & Solution'; const descriptionContent = 'Temukan pilihan produk B2B Industri & Alat Teknik untuk Perusahaan, UMKM & Pemerintah dengan lengkap, mudah dan transparan.'; @@ -24,7 +24,7 @@ export async function getServerSideProps({ res, query }) { const brandsData = {}; const categoriesData = {}; - + let i = 0; const productItems = []; for (const product of products.response.products) { const productUrl = createSlug( @@ -49,6 +49,7 @@ export async function getServerSideProps({ res, query }) { let brandId = product.manufacture?.id ?? null; let categoryId = null; + let category_level_1 = null; if (brandId && brandId in brandsData) { categoryId = brandsData[brandId]?.category_ids?.[0] ?? null; @@ -57,6 +58,23 @@ export async function getServerSideProps({ res, query }) { brandsData[brandId] = solrBrand; categoryId = solrBrand?.category_ids?.[0] ?? null; } + if (product.categories[0]?.id) { + const getProductTemplate = await getProductTemplateId( + product?.productTemplate ?? null + ); + i = i + 1; + const id = + getProductTemplate?.category_parent_ids?.length > 0 + ? getProductTemplate.category_parent_ids[0] + : null; + if (id) { + category_level_1 = await getCategoryById(id); + } else { + category_level_1 = null; + } + } else { + category_level_1 = null; + } if (categoryId && categoryId in categoriesData) { categoryName = categoriesData[categoryId]?.name_s ?? null; @@ -80,7 +98,9 @@ export async function getServerSideProps({ res, query }) { 'g:price': { '#text': `${Math.round(product.lowestPrice.price * PPN)} IDR`, }, - 'g:custom_label_3': { '#text': product.categories[0]?.name || 'Tidak Ada Kategori' }, + 'g:custom_label_3': { + '#text': category_level_1?.name_s || 'Tidak Ada Kategori', + }, }; if (product.stockTotal == 0) { @@ -128,6 +148,13 @@ const getBrandById = async (id) => { return brand.data.response.docs[0] ?? null; }; +const getProductTemplateId = async (id) => { + const category = await axios( + `${process.env.SOLR_HOST}/solr/product/select?q=id:${id}` + ); + return category.data.response.docs[0] ?? null; +}; + const getCategoryById = async (id) => { const category = await axios( `${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}` -- cgit v1.2.3