From 9cbbe5e12f97af023e2f53e4add4c5e5fd9b4667 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 12:13:25 +0700 Subject: fix merchant temp --- src/pages/google_merchant/products/index.js | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/pages/google_merchant/products/index.js b/src/pages/google_merchant/products/index.js index d3cdc514..b6c7bfef 100644 --- a/src/pages/google_merchant/products/index.js +++ b/src/pages/google_merchant/products/index.js @@ -1,31 +1,32 @@ -import productSearchApi from '@/lib/product/api/productSearchApi' -import variantSearchApi from '@/lib/product/api/variantSearchApi' -import _ from 'lodash-contrib' +import productSearchApi from '@/lib/product/api/productSearchApi'; +import variantSearchApi from '@/lib/product/api/variantSearchApi'; +import _ from 'lodash-contrib'; -const limit = 5000 +const limit = 5000; export async function getServerSideProps() { const queries = { limit: 1, priceFrom: 1, - fq: 'image_s:["" TO *]' - } - const products = await variantSearchApi({ query: _.toQuery(queries) }) - const { numFound } = products.response - const pageTotal = Math.ceil(numFound / limit) + fq: 'image_s:["" TO *] AND publish_b:true', + }; + const products = await variantSearchApi({ query: _.toQuery(queries) }); + const { numFound } = products.response; + const pageTotal = Math.ceil(numFound / limit); - return { props: { pageTotal, numFound } } + return { props: { pageTotal, numFound } }; } export default function GoogleMerchantPage({ pageTotal, numFound }) { - const numberArray = Array.from({ length: pageTotal }, (_, index) => index) + const numberArray = Array.from({ length: pageTotal }, (_, index) => index); return (

Google Merchant:

{numberArray.map((number) => { - const currentPage = number + 1 - const remainingProducts = numFound - limit * number - const productCount = currentPage == pageTotal ? remainingProducts : limit + const currentPage = number + 1; + const remainingProducts = numFound - limit * number; + const productCount = + currentPage == pageTotal ? remainingProducts : limit; return ( Page {currentPage} - ({productCount}) Products - ) + ); })}
- ) + ); } -- cgit v1.2.3