列表页显示主商品图片

This commit is contained in:
Edward Yang 2022-12-05 19:16:15 +08:00
parent 9bec24b2cb
commit 6a21576f06
1 changed files with 6 additions and 1 deletions

View File

@ -31,6 +31,11 @@ class ProductSimple extends JsonResource
}
$name = $this->description->name ?? '';
if ($masterSku && $masterSku->images) {
$images = $masterSku->images;
} else {
$images = $this->images ?? [];
}
return [
'id' => $this->id,
@ -47,7 +52,7 @@ class ProductSimple extends JsonResource
'images' => array_map(function ($item) {
return image_resize($item, 400, 400);
}, array_merge($this->images ?? [], $masterSku->images ?? [])),
}, $images),
];
}
}