Make subcategory optional and fix category picker for real tenant data
subcategoryid is no longer required to import a catalogue product — it's a display/grouping hint elsewhere (the codebase already has an "Uncategorized" fallback for subcategoryid=0), so requiring it was pure friction with no correctness payoff. Fixes the category picker at the root: categoryid 2, which tenant 1135's real products actually use, has no row in productcategories at all (not a filter bug — the master data is genuinely missing it). Rather than inventing category master data, adds GET /products/gettenantcategories, which lists categories a tenant's own products actually use (falling back to a synthesized label when the master table has no name), so the import category picker always offers something real instead of an incomplete global list. Also relaxes the subcategory lookup's tenant filter to include unowned/global rows (tenantid NULL or 0), not just exact tenant matches — categoryid 2's real subcategories carry no tenant at all, so the strict filter was hiding them even when a tenant wanted one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ type ProductService interface {
|
||||
DeleteProductLocation(tenantid, locationid, productid int) error
|
||||
ImportCatalogueProduct(reqs []models.ImportCatalogueProductRequest) error
|
||||
GetImportedCatalogueRefs(tenantid int, brand string) ([]models.ImportedCatalogueRef, error)
|
||||
GetTenantCategories(tenantid int) ([]models.TenantCategory, error)
|
||||
}
|
||||
type productService struct {
|
||||
repo repositories.ProductRepository
|
||||
@@ -288,3 +289,7 @@ func (s *productService) GetImportedCatalogueRefs(tenantid int, brand string) ([
|
||||
return s.repo.GetImportedCatalogueRefs(tenantid, brand)
|
||||
}
|
||||
|
||||
func (s *productService) GetTenantCategories(tenantid int) ([]models.TenantCategory, error) {
|
||||
return s.repo.GetTenantCategories(tenantid)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user