fix: add convenience fields to vendor product detail API response
Added title, description, image_url, and additional_images fields to the product detail API response. These fields extract data from the proper sources (translations, primary_image_url) for easier UI display. Fixes image not displaying on product detail page (was using image_url but API returned primary_image_url). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -192,6 +192,19 @@ class VendorProductService:
|
||||
"description": t.description,
|
||||
}
|
||||
|
||||
# Convenience fields for UI (prefer vendor translations, fallback to English)
|
||||
title = None
|
||||
description = None
|
||||
if vendor_translations:
|
||||
# Try English first, then first available language
|
||||
if "en" in vendor_translations:
|
||||
title = vendor_translations["en"].get("title")
|
||||
description = vendor_translations["en"].get("description")
|
||||
elif vendor_translations:
|
||||
first_lang = next(iter(vendor_translations))
|
||||
title = vendor_translations[first_lang].get("title")
|
||||
description = vendor_translations[first_lang].get("description")
|
||||
|
||||
return {
|
||||
"id": product.id,
|
||||
"vendor_id": product.vendor_id,
|
||||
@@ -233,6 +246,11 @@ class VendorProductService:
|
||||
# Translations
|
||||
"marketplace_translations": mp_translations,
|
||||
"vendor_translations": vendor_translations,
|
||||
# Convenience fields for UI display
|
||||
"title": title,
|
||||
"description": description,
|
||||
"image_url": product.primary_image_url,
|
||||
"additional_images": product.additional_images or [],
|
||||
# Timestamps
|
||||
"created_at": product.created_at.isoformat()
|
||||
if product.created_at
|
||||
|
||||
Reference in New Issue
Block a user