feat: add photo URLs to product variants for improved media handling
This commit is contained in:
parent
579a25cdff
commit
76f49e74f5
@ -93,6 +93,17 @@ public function getVariants(Product $product): Collection
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$firstMedia = $allMedia->first();
|
||||
if ($firstMedia) {
|
||||
$variant->photo_url = $this->s3Service->getTemporaryUrl($firstMedia->getPath());
|
||||
$variant->photo_conversion_url = $firstMedia->getGeneratedConversions()->contains('thumb')
|
||||
? $this->s3Service->getTemporaryUrl($firstMedia->getPath('thumb'))
|
||||
: $this->s3Service->getTemporaryUrl($firstMedia->getPath());
|
||||
} else {
|
||||
$variant->photo_url = null;
|
||||
$variant->photo_conversion_url = null;
|
||||
}
|
||||
|
||||
$prices = $variant->productPrices->mapWithKeys(fn ($p) => [$p->type->value => $p->price]);
|
||||
$variant->prices = $prices;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user