From 6a737521366a4b1e6689124e9b5003190fa9d2cd Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sat, 14 Mar 2026 20:47:19 -0700 Subject: [PATCH] Fix empty categories disappearing in unified schema menu builder The unified schema query used INNER JOIN to children, which excluded categories with no items. Changed to direct query with NOT EXISTS template filter so empty categories persist after save+reload. Co-Authored-By: Claude Opus 4.6 --- api/menu/getForBuilder.cfm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/menu/getForBuilder.cfm b/api/menu/getForBuilder.cfm index ea2d1a6..4c00c5a 100644 --- a/api/menu/getForBuilder.cfm +++ b/api/menu/getForBuilder.cfm @@ -205,16 +205,16 @@ try { ", { businessID: businessID }, { datasource: "payfrit" }); } else { - // NEW UNIFIED SCHEMA: Categories are Items at ParentID=0 with children + // NEW UNIFIED SCHEMA: Categories are Items at ParentID=0, CategoryID=0, not templates qCategories = queryTimed(" - SELECT DISTINCT - p.ID as CategoryID, - p.Name as Name, + SELECT + p.ID, + p.Name, p.SortOrder FROM Items p - INNER JOIN Items c ON c.ParentItemID = p.ID WHERE p.BusinessID = :businessID AND p.ParentItemID = 0 + AND (p.CategoryID = 0 OR p.CategoryID IS NULL) AND p.IsActive = 1 AND NOT EXISTS ( SELECT 1 FROM lt_ItemID_TemplateItemID tl WHERE tl.TemplateItemID = p.ID