Merge branch 'feature/m2-featured-product' of github.com:KieIO/grocery-vercel-commerce into feature/m2-add-product-to-cart

This commit is contained in:
DatNguyen
2021-10-04 14:20:07 +07:00
19 changed files with 530 additions and 42 deletions

View File

@@ -3,18 +3,20 @@ import { Cart } from '@commerce/types/cart'
import { CartFragment, SearchResultFragment } from '../schema'
export function normalizeSearchResult(item: SearchResultFragment): Product {
const imageUrl = item.productAsset?.preview ? item.productAsset?.preview + '?w=800&mode=crop' : ''
return {
id: item.productId,
name: item.productName,
description: item.description,
slug: item.slug,
path: item.slug,
images: [{ url: item.productAsset?.preview + '?w=800&mode=crop' || '' }],
variants: [],
images: imageUrl ? [{ url: imageUrl }] : [],
price: {
// TODO: check price
value: (item.priceWithTax as any).min / 100,
currencyCode: item.currencyCode,
},
// TODO: check product option
options: [],
sku: item.sku,
}

View File

@@ -0,0 +1,17 @@
export const getAllFacetsQuery = /* GraphQL */ `
query facets ($options: FacetListOptions) {
facets (options: $options){
totalItems,
items {
id
name
code
values {
id
name
code
}
}
}
}
`