From 84dfa8e6403676ea1049c7f47dc54ae1605fed19 Mon Sep 17 00:00:00 2001 From: abhishek Date: Fri, 24 Jul 2026 11:04:37 +0530 Subject: [PATCH] Add a synthetic "All" category to getappcategories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mobile app needs an "All" tile to browse every product regardless of category. Rather than inserting a real app_category row (which would break once any category-scoped product filter treats it as an actual, empty category), the service now prepends a synthetic entry with categoryid=0 — reusing the "0 = no category filter" convention GetAllProducts already implements in FetchFilteredProducts. Co-Authored-By: Claude Sonnet 5 --- services/utilsService.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/services/utilsService.go b/services/utilsService.go index 09012cf..01d1825 100644 --- a/services/utilsService.go +++ b/services/utilsService.go @@ -48,5 +48,25 @@ func (s *utilsService) GetAppConfig(configID int) (models.Appconfig, error) { } func (s *utilsService) GetAppCategory() ([]models.AppCategory, error) { - return s.repo.GetAppCategory() + categories, err := s.repo.GetAppCategory() + if err != nil { + return nil, err + } + + // "All" is a synthetic pseudo-category, not a real app_category row — it + // must never be inserted into app_category itself, since product-listing + // filters (e.g. ProductController.GetAllProducts) already treat + // categoryid=0 as "no category filter". Keeping this row's id at 0 reuses + // that existing convention instead of adding a new one. + all := models.AppCategory{ + Categoryid: 0, + Categoryname: "All", + Categorytype: 7, + Sortorder: 0, + Crossaxis: 1, + Mainaxis: 1, + Status: "Active", + } + + return append([]models.AppCategory{all}, categories...), nil }