From 53c8d78dc2a7d5f0a7fe0d562b0e685744d900f1 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 25 May 2023 09:02:56 +0700 Subject: Fixing google merchant xml --- src/pages/google_merchant/products/[page].js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js index 7db826bb..aaa4dde4 100644 --- a/src/pages/google_merchant/products/[page].js +++ b/src/pages/google_merchant/products/[page].js @@ -24,14 +24,21 @@ export async function getServerSideProps({ res, query }) { products.response.products.forEach((product) => { const productUrl = createSlug('/shop/product/', product.name, product.id, true) const productId = product.code != '' ? product.code : product.id - const productDescription = product.description?.replace(/<[^>]*>/g, ' ') || '' + const regexHtmlTags = /(<([^>]+)>)/gi + product.description = product.description?.replace(regexHtmlTags, ' ').trim() + const defaultProductDescription = + 'Indoteknik.com menawarkan berbagai produk industri, konstruksi, dan teknik terpercaya. Temukan mesin industri, peralatan listrik, alat pengukur, dan banyak lagi. Pengalaman berbelanja mudah dengan deskripsi produk lengkap, spesifikasi teknis, dan gambar jelas. Pembayaran aman, pengiriman cepat ke seluruh Indonesia. Solusi lengkap untuk kebutuhan Kantor, Industri & Teknik Anda.' + + if (!product.description) { + product.description = defaultProductDescription + } const item = { 'g:id': { '#text': productId }, - 'g:title': { '#text': `` }, - 'g:description': { '#text': `` }, + 'g:title': { '#text': toTitleCase(product.name) }, + 'g:description': { '#text': product.description }, 'g:link': { '#text': productUrl }, - 'g:image': { '#text': product.image }, + 'g:image_link': { '#text': product.image }, 'g:condition': { '#text': 'new' }, 'g:availability': { '#text': 'in_stock' }, 'g:brand': { '#text': product.manufacture?.name || '' }, -- cgit v1.2.3