fix: add include_all param in get all master product

This commit is contained in:
Hafizh A. Y
2026-03-09 00:47:37 +07:00
parent e6159e4f90
commit 1fc6cb051d
3 changed files with 12 additions and 3 deletions
@@ -229,9 +229,9 @@ 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)
// Depletion master products are system products and often stored with is_visible = false.
// When requested explicitly via is_depletion=true, include hidden records.
if params.IsDepletion == nil || !*params.IsDepletion {
// 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 {
db = db.Where("is_visible = ?", true)
}
if params.Search != "" {