Expand variants
This commit is contained in:
@@ -4,16 +4,19 @@ export default async (req, res) => {
|
||||
const productService = req.scope.resolve("productService")
|
||||
let product = await productService.retrieve(id)
|
||||
|
||||
product = await productService.decorate(product, [
|
||||
"title",
|
||||
"description",
|
||||
"tags",
|
||||
"handle",
|
||||
"images",
|
||||
"options",
|
||||
"variants",
|
||||
"published",
|
||||
])
|
||||
product = await productService.decorate(
|
||||
product,
|
||||
[
|
||||
"title",
|
||||
"description",
|
||||
"tags",
|
||||
"handle",
|
||||
"images",
|
||||
"options",
|
||||
"published",
|
||||
],
|
||||
["variants"]
|
||||
)
|
||||
|
||||
res.json({ product })
|
||||
}
|
||||
|
||||
@@ -5,16 +5,19 @@ export default async (req, res) => {
|
||||
products = await Promise.all(
|
||||
products.map(
|
||||
async product =>
|
||||
await productService.decorate(product, [
|
||||
"title",
|
||||
"description",
|
||||
"tags",
|
||||
"handle",
|
||||
"images",
|
||||
"options",
|
||||
"variants",
|
||||
"published",
|
||||
])
|
||||
await productService.decorate(
|
||||
product,
|
||||
[
|
||||
"title",
|
||||
"description",
|
||||
"tags",
|
||||
"handle",
|
||||
"images",
|
||||
"options",
|
||||
"published",
|
||||
],
|
||||
["variants"]
|
||||
)
|
||||
)
|
||||
)
|
||||
res.json({ products })
|
||||
|
||||
@@ -4,10 +4,10 @@ export default async (req, res) => {
|
||||
const { id } = req.params
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
title: Validator.string().required(),
|
||||
title: Validator.string(),
|
||||
description: Validator.string().optional(),
|
||||
tags: Validator.string().optional(),
|
||||
handle: Validator.string().required(),
|
||||
handle: Validator.string(),
|
||||
images: Validator.array()
|
||||
.items(Validator.string())
|
||||
.optional(),
|
||||
@@ -34,9 +34,8 @@ export default async (req, res) => {
|
||||
"handle",
|
||||
"images",
|
||||
"options",
|
||||
"variants",
|
||||
"published",
|
||||
])
|
||||
], ["variants"])
|
||||
res.json({ product: newProduct })
|
||||
} catch (err) {
|
||||
throw err
|
||||
|
||||
Reference in New Issue
Block a user