diff options
| -rw-r--r-- | src/pages/google_merchant/products/index.js | 33 |
1 files 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 ( <div className='grid grid-cols-1 gap-y-3 p-4'> <h1 className='text-h-lg font-semibold mb-3'>Google Merchant:</h1> {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 ( <a key={number} @@ -36,8 +37,8 @@ export default function GoogleMerchantPage({ pageTotal, numFound }) { > Page {currentPage} - ({productCount}) Products </a> - ) + ); })} </div> - ) + ); } |
