mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Continue Migration, almost done
This commit is contained in:
@@ -22,6 +22,7 @@ import MarkerCardModal from '@components/common/Room/MarkerCardModal/MarkerCardM
|
||||
import { useDisclosure } from '@chakra-ui/react'
|
||||
|
||||
import decadesManifest from '../../../static_data/decadesManifest.json'
|
||||
import productDetailsMetafields from '../../../static_data/productDetailsMetafields.json'
|
||||
import {
|
||||
MarkerData,
|
||||
MarkerJson,
|
||||
@@ -123,7 +124,14 @@ export async function getStaticProps({
|
||||
continue
|
||||
|
||||
const productPromise = commerce.getProduct({
|
||||
variables: { slug: productMarker.markerSource },
|
||||
variables: {
|
||||
slug: productMarker.markerSource,
|
||||
withMetafields: [
|
||||
{ namespace: 'custom', key: 'nazionalit_' },
|
||||
{ namespace: 'custom', key: 'descrizione_tecnica' },
|
||||
{ namespace: 'custom', key: 'descrizione_storica' },
|
||||
],
|
||||
},
|
||||
config,
|
||||
preview,
|
||||
})
|
||||
@@ -132,8 +140,6 @@ export async function getStaticProps({
|
||||
}
|
||||
}
|
||||
|
||||
console.log(products)
|
||||
|
||||
if (!products) {
|
||||
throw new Error(`Products associated with markers not found`)
|
||||
}
|
||||
|
@@ -10,14 +10,16 @@ import { useRouter } from 'next/router'
|
||||
import { Layout } from '@components/common'
|
||||
import { ProductView } from '@components/product'
|
||||
|
||||
// Used by the Shopify Example
|
||||
const withMetafields = [
|
||||
{ namespace: 'reviews', key: 'rating' },
|
||||
{ namespace: 'reviews', key: 'count' },
|
||||
{ namespace: 'my_fields', key: 'width' },
|
||||
{ namespace: 'my_fields', key: 'weight' },
|
||||
{ namespace: 'my_fields', key: 'length' },
|
||||
]
|
||||
import productDetailsMetafields from '../../static_data/productDetailsMetafields.json'
|
||||
|
||||
const withMetafields = productDetailsMetafields.metafields[0].names.map(
|
||||
(metafield: any) => {
|
||||
return {
|
||||
namespace: metafield.namespace,
|
||||
key: metafield.key,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
export async function getStaticProps({
|
||||
params,
|
||||
@@ -28,6 +30,9 @@ export async function getStaticProps({
|
||||
const config = { locale, locales }
|
||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
||||
|
||||
console.log(withMetafields)
|
||||
|
||||
const productPromise = commerce.getProduct({
|
||||
variables: {
|
||||
slug: params!.slug,
|
||||
@@ -47,6 +52,8 @@ export async function getStaticProps({
|
||||
const { product } = await productPromise
|
||||
const { products: relatedProducts } = await allProductsPromise
|
||||
|
||||
console.log(product)
|
||||
|
||||
if (!product) {
|
||||
return {
|
||||
notFound: true,
|
||||
|
Reference in New Issue
Block a user