diff --git a/controllers/ParseController.go b/controllers/ParseController.go index 9cf64d9..b651124 100644 --- a/controllers/ParseController.go +++ b/controllers/ParseController.go @@ -5,6 +5,7 @@ import ( helper "db_service/pkg" "db_service/repositories" "encoding/json" + "errors" "fmt" "gorm.io/driver/mysql" "gorm.io/gorm" @@ -56,14 +57,10 @@ func ParseLink(w http.ResponseWriter, route *http.Request) { //Preload("Proudct.AttributeValues","attribute_id in(11,13)"). First(&productFlat, "sku = ?", jsonProduct.ProductGroupID).Error - if err != nil { + if err != nil && errors.Is(err, gorm.ErrRecordNotFound) { helper.Error(err) - return - } - - if productFlat.Sku == "" { err = ImportProduct(jsonProduct, baza) - } else { + } else if err == nil { err = UpdateProduct(jsonProduct, baza, productFlat) }