Debug: Enhanced logging for variant loading investigation
This commit is contained in:
parent
6f4befa188
commit
45da991945
@ -193,15 +193,23 @@ public class ProductService : IProductService
|
||||
if (product == null) return null;
|
||||
|
||||
// Manually load variants - using fresh query to avoid Contains() json_each bug in EF Core 9 + SQLite
|
||||
var variants = await _context.ProductVariants
|
||||
.Where(v => v.ProductId == id && v.IsActive)
|
||||
.OrderBy(v => v.SortOrder)
|
||||
.ToListAsync();
|
||||
// Load ALL variants first to debug
|
||||
var allVariants = await _context.ProductVariants.ToListAsync();
|
||||
Console.WriteLine($"[DEBUG GetProductById] Total variants in DB: {allVariants.Count}");
|
||||
Console.WriteLine($"[DEBUG GetProductById] Looking for ProductId: {id} (Type: {id.GetType().Name})");
|
||||
|
||||
Console.WriteLine($"[DEBUG GetProductById] ProductId: {id}, Variants loaded: {variants.Count}");
|
||||
var matchingByProductId = allVariants.Where(v => v.ProductId == id).ToList();
|
||||
Console.WriteLine($"[DEBUG GetProductById] Matching by ProductId: {matchingByProductId.Count}");
|
||||
|
||||
var matchingByIsActive = allVariants.Where(v => v.IsActive).ToList();
|
||||
Console.WriteLine($"[DEBUG GetProductById] Matching by IsActive: {matchingByIsActive.Count}");
|
||||
|
||||
var variants = allVariants.Where(v => v.ProductId == id && v.IsActive).OrderBy(v => v.SortOrder).ToList();
|
||||
|
||||
Console.WriteLine($"[DEBUG GetProductById] Final variants loaded: {variants.Count}");
|
||||
foreach (var v in variants.Take(3))
|
||||
{
|
||||
Console.WriteLine($"[DEBUG GetProductById] - {v.VariantType}: {v.Name}");
|
||||
Console.WriteLine($"[DEBUG GetProductById] - {v.VariantType}: {v.Name}, ProductId: {v.ProductId}");
|
||||
}
|
||||
|
||||
return new ProductDto
|
||||
|
||||
Loading…
Reference in New Issue
Block a user