bugs on variant id

This commit is contained in:
2026-08-29 16:45:47 +05:30
parent c5109bf216
commit 76554d26e5
8 changed files with 204 additions and 1 deletions

View File

@@ -146,3 +146,48 @@ func (ctl *CatalogueController) GetProductBySKU(c *fiber.Ctx) error {
"details": product,
})
}
// GetProductByImageID resolves a catalogue row by the id the ingest pipeline
// treats as canonical, so a caller holding an ingest manifest can find the
// catalogueid it needs to import the product into a shop.
func (ctl *CatalogueController) GetProductByImageID(c *fiber.Ctx) error {
brand := c.Query("brand")
imageID := c.Query("image_id")
if brand == "" || imageID == "" {
return c.JSON(fiber.Map{
"code": 400,
"message": "brand and image_id are required",
"status": false,
})
}
product, err := ctl.catalogueService.GetProductByImageID(brand, imageID)
if err != nil {
if errors.Is(err, repositories.ErrUnknownBrand) {
return c.JSON(fiber.Map{
"code": 400,
"message": "Unknown brand: " + brand,
"status": false,
})
}
return c.JSON(fiber.Map{
"code": 500,
"message": "Failed to fetch catalogue product",
"status": false,
})
}
if product == nil {
return c.JSON(fiber.Map{
"code": 404,
"message": "Product not found",
"status": false,
})
}
return c.JSON(fiber.Map{
"code": http.StatusOK,
"message": "Success",
"status": true,
"details": product,
})
}