From df3e3b1f0ab0ad3bf99f07c1af4fa35ca8c1b10a Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 12 Oct 2023 13:22:29 +0700 Subject: bugs fix query solr varaint --- src/pages/api/shop/product-detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 22a53df2..247f2a04 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -8,7 +8,7 @@ export default async function handler(req, res) { ) 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` + `/solr/variants/select?q=template_id_i:${req.query.id}&q.op=OR&indent=true&rows=100&fq=-publish_b:false` ) let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth let result = productMappingSolr(productTemplate.data.response.docs, auth || false) -- cgit v1.2.3 From 5802ab415b4b42d6b277fcc0db7447adb3ae66a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 16 Oct 2023 15:58:07 +0700 Subject: Fix variant solr map --- src/pages/api/shop/variant.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/pages/api/shop/variant.js b/src/pages/api/shop/variant.js index 30213cc3..302b5d4a 100644 --- a/src/pages/api/shop/variant.js +++ b/src/pages/api/shop/variant.js @@ -103,17 +103,12 @@ const escapeSolrQuery = (query) => { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 - let priceDiscount = product.price_discount_f || 0 - let discountPercentage = product.discount_f || 0 + let price = product.price_tier1_v2_f || 0 + let priceDiscount = 0 + let discountPercentage = 0 - if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc + if (pricelist && product?.[`price_${pricelist}_f`] < price) { + price = product?.[`price_${pricelist}_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3 From a8fb3ca1661297362e5e1a111121dd6a5e54b151 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 17 Oct 2023 13:55:56 +0700 Subject: Fix price filter on variant solr --- src/pages/api/shop/variant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pages/api/shop/variant.js b/src/pages/api/shop/variant.js index 302b5d4a..249d087e 100644 --- a/src/pages/api/shop/variant.js +++ b/src/pages/api/shop/variant.js @@ -54,7 +54,7 @@ export default async function handler(req, res) { if (priceFrom > 0 || priceTo > 0) { parameter.push( - `fq=price_discount_f:[${priceFrom == '' ? '*' : priceFrom} TO ${ + `fq=price_tier1_v2_f:[${priceFrom == '' ? '*' : priceFrom} TO ${ priceTo == '' ? '*' : priceTo }]` ) -- cgit v1.2.3 From b0f07da928f1956946fb36db8983718962b6bcee Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 18 Oct 2023 14:04:48 +0700 Subject: change label call for price to call for inquiry --- src/lib/cart/components/Cartheader.jsx | 2 +- src/lib/checkout/components/Checkout.jsx | 4 ++-- src/lib/checkout/components/CheckoutOld.jsx | 4 ++-- src/lib/product/components/Product/ProductDesktop.jsx | 2 +- src/lib/product/components/ProductCard.jsx | 8 ++++---- src/lib/variant/components/VariantCard.jsx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx index 901b1501..b3cf849b 100644 --- a/src/lib/cart/components/Cartheader.jsx +++ b/src/lib/cart/components/Cartheader.jsx @@ -235,7 +235,7 @@ const Cardheader = (cartCount) => { rel='noopener noreferrer' target='_blank' > - Call For Price + Call for Inquiry )} diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index e2c1a85b..85221e5d 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1069,7 +1069,7 @@ const Checkout = () => {
{product.price.priceDiscount > 0 ? currencyFormat(product?.price?.priceDiscount) - : 'Call For Price'} + : 'Call for Inquiry'}
)} @@ -1090,7 +1090,7 @@ const Checkout = () => { })} className='underline' > - Call For Price{' '} + Call for Inquiry{' '} )} diff --git a/src/lib/checkout/components/CheckoutOld.jsx b/src/lib/checkout/components/CheckoutOld.jsx index 6852059e..d57fbd66 100644 --- a/src/lib/checkout/components/CheckoutOld.jsx +++ b/src/lib/checkout/components/CheckoutOld.jsx @@ -486,7 +486,7 @@ const Checkout = () => {
{product.price.priceDiscount > 0 ? currencyFormat(product?.price?.priceDiscount) - : 'Call For Price'} + : 'Call for Inquiry'}
@@ -501,7 +501,7 @@ const Checkout = () => { })} className='underline' > - Call For Price{' '} + Call for Inquiry{' '} )} diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 47e98c1a..aa771eab 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -625,7 +625,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { rel='noopener noreferrer' target='_blank' > - Call for price + Call for Inquiry )} diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 3b96ac32..bc2174e4 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -103,7 +103,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.lowestPrice.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice.priceDiscount) ) : ( - Call for price + Call for Inquiry )} @@ -118,7 +118,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { ) : ( - Call for price + Call for Inquiry )} )} @@ -209,7 +209,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.lowestPrice?.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice?.priceDiscount) ) : ( - Call for price + Call for Inquiry )} @@ -224,7 +224,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { ) : ( - Call for price + Call for Inquiry )} )} diff --git a/src/lib/variant/components/VariantCard.jsx b/src/lib/variant/components/VariantCard.jsx index 64b6d146..6b06bc31 100644 --- a/src/lib/variant/components/VariantCard.jsx +++ b/src/lib/variant/components/VariantCard.jsx @@ -68,7 +68,7 @@ const VariantCard = ({ product, openOnClick = true, buyMore = false }) => { })} className='underline text-danger-500' > - Call For Price{' '} + Call for Inquiry{' '} )}

-- cgit v1.2.3 From b4b17e22832a4665042a45030b77c3744fe61534 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 18 Oct 2023 14:43:26 +0700 Subject: Add category name on google merchant product xml --- src/pages/google_merchant/products/[page].js | 45 ++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index d6309090..c8b4079b 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -2,6 +2,7 @@ import { createSlug } from '@/core/utils/slug' import toTitleCase from '@/core/utils/toTitleCase' import productSearchApi from '@/lib/product/api/productSearchApi' import variantSearchApi from '@/lib/product/api/variantSearchApi' +import axios from 'axios' import _ from 'lodash-contrib' import { create } from 'xmlbuilder' @@ -21,8 +22,11 @@ export async function getServerSideProps({ res, query }) { } const products = await variantSearchApi({ query: _.toQuery(queries) }) + const brandsData = {} + const categoriesData = {} + const productItems = [] - products.response.products.forEach((product) => { + for (const product of products.response.products) { const productUrl = createSlug('/shop/product/variant/', product.name, product.id, true) const productId = product.code != '' ? product.code : product.id const regexHtmlTags = /(<([^>]+)>)/gi @@ -34,6 +38,27 @@ export async function getServerSideProps({ res, query }) { product.description = defaultProductDescription } + let categoryName = null + + let brandId = product.manufacture?.id ?? null + let categoryId = null + + if (brandId && brandId in brandsData) { + categoryId = brandsData[brandId].category_ids?.[0] ?? null + } else { + const solrBrand = await getBrandById(brandId) + brandsData[brandId] = solrBrand + categoryId = solrBrand?.category_ids?.[0] ?? null + } + + if (categoryId && categoryId in categoriesData) { + categoryName = categoriesData[categoryId].name_s ?? null + } else { + const solrCategory = await getCategoryById(categoryId) + categoriesData[categoryId] = solrCategory + categoryName = solrCategory?.name_s ?? null + } + const availability = 'in_stock' const item = { @@ -47,20 +72,24 @@ export async function getServerSideProps({ res, query }) { 'g:brand': { '#text': product.manufacture?.name || '' }, 'g:price': { '#text': `${Math.round(product.lowestPrice.price * 1.11)} IDR` } } - + if (product.stockTotal == 0) { item['g:custom_label_0'] = { '#text': 'Stok Tidak Tersedia' } } else { item['g:custom_label_1'] = { '#text': 'Stok Tersedia' } } + if (categoryName) { + item['g:custom_label_2'] = { '#text': categoryName } + } + if (product.lowestPrice.discountPercentage > 0) { item['g:sale_price'] = { '#text': `${Math.round(product.lowestPrice.priceDiscount * 1.11)} IDR` } } productItems.push(item) - }) + } const googleMerchant = { rss: { @@ -82,6 +111,16 @@ export async function getServerSideProps({ res, query }) { return { props: {} } } +const getBrandById = async (id) => { + const brand = await axios(`${process.env.SOLR_HOST}/solr/brands/select?q=id:${id}`) + return brand.data.response.docs[0] ?? null +} + +const getCategoryById = async (id) => { + const category = await axios(`${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}`) + return category.data.response.docs[0] ?? null +} + export default function GoogleMerchantPage() { return null } -- cgit v1.2.3