Debug: Add console logging to variant loading
This commit is contained in:
parent
8d1e3d153c
commit
3a2ef481b0
@ -25,16 +25,28 @@ public class ProductService : IProductService
|
||||
.Where(p => p.IsActive)
|
||||
.ToListAsync();
|
||||
|
||||
Console.WriteLine($"[DEBUG] Loaded {products.Count} products");
|
||||
|
||||
// Manually load variants for all products
|
||||
var productIds = products.Select(p => p.Id).ToList();
|
||||
Console.WriteLine($"[DEBUG] Product IDs: {string.Join(", ", productIds.Select(id => id.ToString()))}");
|
||||
|
||||
var allVariants = await _context.ProductVariants
|
||||
.Where(v => productIds.Contains(v.ProductId))
|
||||
.ToListAsync();
|
||||
|
||||
Console.WriteLine($"[DEBUG] Loaded {allVariants.Count} total variants from database");
|
||||
foreach (var v in allVariants.Take(5))
|
||||
{
|
||||
Console.WriteLine($"[DEBUG] - Variant: {v.Id}, ProductId: {v.ProductId}, Type: {v.VariantType}, Name: {v.Name}");
|
||||
}
|
||||
|
||||
// Group variants by ProductId for quick lookup
|
||||
var variantsByProduct = allVariants.GroupBy(v => v.ProductId)
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
|
||||
Console.WriteLine($"[DEBUG] Grouped variants into {variantsByProduct.Count} product groups");
|
||||
|
||||
return products.Select(p => new ProductDto
|
||||
{
|
||||
Id = p.Id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user