summaryrefslogtreecommitdiff
path: root/src/pages/api/shop
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/api/shop')
-rw-r--r--src/pages/api/shop/variant-detail.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pages/api/shop/variant-detail.js b/src/pages/api/shop/variant-detail.js
new file mode 100644
index 00000000..fadbe000
--- /dev/null
+++ b/src/pages/api/shop/variant-detail.js
@@ -0,0 +1,18 @@
+import { productMappingSolr, variantsMappingSolr } from '@/utils/solrMapping'
+import axios from 'axios'
+
+export default async function handler(req, res) {
+ try {
+ let productVariants = await axios(
+ process.env.SOLR_HOST +
+ `/solr/variants/select?q=id:${req.query.id}&q.op=OR&indent=true`
+ )
+ let auth = req.query.auth === 'false' ? JSON.parse(req.query.auth) : req.query.auth
+ let result = variantsMappingSolr('',productVariants.data.response.docs, auth || false)
+
+ res.status(200).json(result)
+ } catch (error) {
+ console.error('Error fetching data from Solr:', error)
+ res.status(500).json({ error: 'Internal Server Error' })
+ }
+} \ No newline at end of file