variants as a single product

This commit is contained in:
2026-09-03 10:43:05 +05:30
parent 2401158190
commit da0e9d987e
7 changed files with 205 additions and 4 deletions

View File

@@ -401,6 +401,20 @@ func (ctl *ProductController) GetAllProducts(c *fiber.Ctx) error {
// list and the figure beside it cannot disagree.
if err == nil && isAppRequest(c) {
details = services.InStockOnlyGrouped(details)
// One product, three sizes — not three products.
//
// A shop stocking Aachi Baby Fryums in 100g, 500g and 1kg has three
// product rows, each with its own price and its own shelf. The shopper
// should meet ONE listing and pick the size; the sizes travel with the
// parent in `variantoptions`, so nothing becomes unreachable.
//
// Best-effort, like the stock filter above: if the lookup fails the
// shopper sees the three rows they see today, which is worse than the
// grouping and much better than an error.
if isChild, cErr := ctl.productService.VariantChildIDs(tenantID); cErr == nil {
details = services.WithoutVariantChildren(details, isChild)
}
}
if err != nil {
return c.JSON(fiber.Map{