summaryrefslogtreecommitdiff
path: root/src/pages/google_merchant/products/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/google_merchant/products/index.js')
-rw-r--r--src/pages/google_merchant/products/index.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/pages/google_merchant/products/index.js b/src/pages/google_merchant/products/index.js
new file mode 100644
index 00000000..38b37d29
--- /dev/null
+++ b/src/pages/google_merchant/products/index.js
@@ -0,0 +1,35 @@
+import productSearchApi from '@/lib/product/api/productSearchApi'
+import _ from 'lodash-contrib'
+
+export async function getServerSideProps() {
+ const limit = 5000
+ const queries = {
+ limit: 1,
+ priceFrom: 1,
+ fq: 'image_s:["" TO *]'
+ }
+ const products = await productSearchApi({ query: _.toQuery(queries) })
+ const pageTotal = Math.ceil(products.response.numFound / limit)
+
+ return { props: { pageTotal } }
+}
+
+export default function GoogleMerchantPage({ pageTotal }) {
+ 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'>Google Merchant:</h1>
+ {numberArray.map((number) => (
+ <a
+ key={number}
+ href={`/google_merchant/products/${number + 1}.xml`}
+ className='block font-medium text-indigo-600'
+ target='_blank'
+ rel='noreferrer'
+ >
+ Page {number + 1}
+ </a>
+ ))}
+ </div>
+ )
+}