fix: is depletion hidden

This commit is contained in:
Adnan Zahir
2026-03-09 22:54:18 +07:00
parent cb9c202b29
commit a1b1841695
@@ -229,9 +229,17 @@ func (s productService) GetAll(c *fiber.Ctx, params *validation.Query) ([]entity
products, total, err := s.Repository.GetAll(c.Context(), offset, params.Limit, func(db *gorm.DB) *gorm.DB {
db = s.withRelations(db)
includeAll := params.IncludeAll != nil && *params.IncludeAll
// Avoid overlapping behavior: when is_depletion filter is used, keep visible-only catalog.
if params.IsDepletion != nil {
includeAll = false
}
// Default: show only visible products.
// include_all=true can be used to fetch all records (including hidden/system products).
if params.IncludeAll == nil || !*params.IncludeAll {
// include_all=true can be used to fetch all records (including hidden/system products),
// except when is_depletion is explicitly requested.
if !includeAll {
db = db.Where("is_visible = ?", true)
}
if params.Search != "" {