summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pages/google_merchant/products/[page].js16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 2a53f7c0..d2371eb7 100644
--- a/src/pages/google_merchant/products/[page].js
+++ b/src/pages/google_merchant/products/[page].js
@@ -33,7 +33,7 @@ export async function getServerSideProps({ res, query }) {
'/shop/product/variant/',
product.name,
product.id,
- true
+ true,
);
const productId = product.code != '' ? product.code : product.id;
const regexHtmlTags = /(<([^>]+)>)/gi;
@@ -62,7 +62,7 @@ export async function getServerSideProps({ res, query }) {
}
if (product.categories[0]?.id) {
const getProductTemplate = await getProductTemplateId(
- product?.productTemplate ?? null
+ product?.productTemplate ?? null,
);
i = i + 1;
const id =
@@ -112,8 +112,10 @@ export async function getServerSideProps({ res, query }) {
item['g:custom_label_1'] = { '#text': 'Stok Tersedia' };
}
- if (categoryName) {
- item['g:custom_label_2'] = { '#text': categoryName };
+ if (product.categories?.[0]?.name) {
+ item['g:custom_label_2'] = {
+ '#text': product.categories[0].name,
+ };
}
if (product.lowestPrice.discountPercentage > 0) {
@@ -146,21 +148,21 @@ export async function getServerSideProps({ res, query }) {
const getBrandById = async (id) => {
const brand = await axios(
- `${process.env.SOLR_HOST}/solr/brands/select?q=id:${id}`
+ `${process.env.SOLR_HOST}/solr/brands/select?q=id:${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}`
+ `${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}`
+ `${process.env.SOLR_HOST}/solr/categories/select?q=id:${id}`,
);
return category.data.response.docs[0] ?? null;
};