product categories

This commit is contained in:
2026-09-07 17:28:38 +05:30
parent f1b3a5eba4
commit c699a400c3
4 changed files with 222 additions and 6 deletions

View File

@@ -40,6 +40,7 @@ type ProductService interface {
GetImportedCatalogueRefs(tenantid int, brand string) ([]models.ImportedCatalogueRef, error)
RelinkCatalogue(tenantid int, dryRun bool) (*RelinkReport, error)
GetTenantCategories(tenantid int) ([]models.TenantCategory, error)
EnsureTenantCategories(tenantid int, names []string) (map[string]int, error)
PublishProduct(tenantID, productID int, price, taxPercent float64) (int, error)
UnpublishProduct(tenantID, productID int) (int, error)
}
@@ -499,6 +500,17 @@ func (s *productService) GetTenantCategories(tenantid int) ([]models.TenantCateg
return s.repo.GetTenantCategories(tenantid)
}
// EnsureTenantCategories turns category NAMES into this tenant's category ids,
// creating the ones that do not exist yet.
//
// The console works out a product's category from its title with a
// deterministic ladder, but the customer app browses by categoryid and rejects
// 0 — so an import has to exchange its names for ids before it creates
// anything. Idempotent: importing the same sheet twice creates no duplicates.
func (s *productService) EnsureTenantCategories(tenantid int, names []string) (map[string]int, error) {
return s.repo.EnsureTenantCategories(tenantid, names)
}
// PublishProduct releases a product to every outlet the tenant runs.
//
// The price check lives in the repository rather than here, so it holds for any