feat: update CSV import to support multi-language translations
- Add language parameter to import endpoints and background tasks - Extract translation fields (title, description, short_description) - Create/update MarketplaceProductTranslation records during import - Add MarketplaceProductTranslationSchema for API responses - Map product_type column to product_type_raw to avoid enum conflict - Parse prices to numeric format (price_numeric, sale_price_numeric) - Update marketplace product service for translation-based lookups - Update CSV export to retrieve titles from translations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# app/tasks/background_tasks.py
|
||||
"""Background tasks for marketplace imports."""
|
||||
|
||||
import logging
|
||||
from datetime import UTC, datetime
|
||||
|
||||
@@ -14,10 +16,20 @@ async def process_marketplace_import(
|
||||
job_id: int,
|
||||
url: str,
|
||||
marketplace: str,
|
||||
vendor_id: int, # FIXED: Changed from vendor_name to vendor_id
|
||||
vendor_id: int,
|
||||
batch_size: int = 1000,
|
||||
language: str = "en",
|
||||
):
|
||||
"""Background task to process marketplace CSV import."""
|
||||
"""Background task to process marketplace CSV import.
|
||||
|
||||
Args:
|
||||
job_id: ID of the MarketplaceImportJob record
|
||||
url: URL to the CSV file
|
||||
marketplace: Name of the marketplace (e.g., 'Letzshop')
|
||||
vendor_id: ID of the vendor
|
||||
batch_size: Number of rows to process per batch
|
||||
language: Language code for translations (default: 'en')
|
||||
"""
|
||||
db = SessionLocal()
|
||||
csv_processor = CSVProcessor()
|
||||
job = None
|
||||
@@ -50,16 +62,17 @@ async def process_marketplace_import(
|
||||
|
||||
logger.info(
|
||||
f"Processing import: Job {job_id}, Marketplace: {marketplace}, "
|
||||
f"Vendor: {vendor.name} ({vendor.vendor_code})"
|
||||
f"Vendor: {vendor.name} ({vendor.vendor_code}), Language: {language}"
|
||||
)
|
||||
|
||||
# Process CSV with vendor_id
|
||||
# Process CSV with vendor name and language
|
||||
result = await csv_processor.process_marketplace_csv_from_url(
|
||||
url,
|
||||
marketplace,
|
||||
vendor_id, # FIXED: Pass vendor_id instead of vendor_name
|
||||
batch_size,
|
||||
db,
|
||||
url=url,
|
||||
marketplace=marketplace,
|
||||
vendor_name=vendor.name, # Pass vendor name to CSV processor
|
||||
batch_size=batch_size,
|
||||
db=db,
|
||||
language=language, # Pass language for translations
|
||||
)
|
||||
|
||||
# Update job with results
|
||||
|
||||
Reference in New Issue
Block a user