now products have different options, like different parameters
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled

This commit is contained in:
Priec
2026-06-22 15:44:02 +02:00
parent 29854a972b
commit 3f798432a0
52 changed files with 1281 additions and 628 deletions

View File

@@ -4,7 +4,7 @@ use loco_rs::prelude::*;
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
use crate::{
models::_entities::{categories, products},
models::_entities::{categories, product_variants, products},
shared::slug::slugify,
};
@@ -157,14 +157,11 @@ pub async fn seed_catalog(ctx: &AppContext) -> Result<()> {
let now = chrono::Utc::now();
products::ActiveModel {
let product = products::ActiveModel {
name: Set(item.name.to_string()),
slug: Set(product_slug),
description: Set(Some(item.description.to_string())),
price_cents: Set(item.price_cents),
currency: Set("EUR".to_string()),
sku: Set(item.sku.map(|s| s.to_string())),
stock: Set(item.stock),
published: Set(true),
published_at: Set(Some(now.into())),
category_id: Set(category.map(|c| c.id)),
@@ -172,6 +169,20 @@ pub async fn seed_catalog(ctx: &AppContext) -> Result<()> {
}
.insert(&ctx.db)
.await?;
// Each seed product ships as a single default (unlabelled) variant
// carrying its price/stock/sku.
product_variants::ActiveModel {
product_id: Set(product.id),
label: Set(String::new()),
position: Set(0),
sku: Set(item.sku.map(|s| s.to_string())),
stock: Set(item.stock),
price_cents: Set(item.price_cents),
..Default::default()
}
.insert(&ctx.db)
.await?;
}
Ok(())