nemetyan kod
This commit is contained in:
parent
55afd88e31
commit
d159616a44
|
|
@ -402,27 +402,28 @@ func (importer *Importer) importVariant(product models.Product) (*gm.Product, er
|
||||||
|
|
||||||
if err1:= json.Unmarshal((byteErr), &newError);err1!=nil{
|
if err1:= json.Unmarshal((byteErr), &newError);err1!=nil{
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
log.Println(err1)
|
log.Println(err1,"err2")
|
||||||
return nil, err
|
return nil, err1
|
||||||
}
|
}
|
||||||
|
|
||||||
if newError.Number == 1062{
|
if newError.Number == 1062{
|
||||||
var barProduct gm.Product
|
var barProduct gm.Product
|
||||||
if err2 := tx.First(&barProduct,"sku = ?",mainPorduct.Sku).Error;err2 !=nil {
|
if err2 := tx.First(&barProduct,"sku = ?",mainPorduct.Sku).Error;err2 !=nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
log.Println(err2)
|
log.Println(err2,"err3")
|
||||||
return nil, err2
|
return nil, err2
|
||||||
}
|
}
|
||||||
|
|
||||||
if err3:= tx.Model(&barProduct).Association("Categories").Append(mainPorduct.Categories); err3!=nil{
|
if err3:= tx.Model(&barProduct).Association("Categories").Append(mainPorduct.Categories); err3!=nil{
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
log.Println(err3)
|
log.Println(err3,"err4")
|
||||||
return nil, err3
|
return nil, err3
|
||||||
}
|
}
|
||||||
|
|
||||||
return &barProduct,tx.Commit().Error;
|
return &barProduct,tx.Commit().Error;
|
||||||
}else{
|
}else{
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
log.Println(err,"er1")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,6 +433,7 @@ func (importer *Importer) importVariant(product models.Product) (*gm.Product, er
|
||||||
|
|
||||||
if err := tx.Create(&mainFlat).Error; err != nil {
|
if err := tx.Create(&mainFlat).Error; err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
log.Println(err,"er5")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -477,7 +479,7 @@ func (importer *Importer) importVariant(product models.Product) (*gm.Product, er
|
||||||
|
|
||||||
if len(sizeVariants) == 0 {
|
if len(sizeVariants) == 0 {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return nil, errors.New("siz variantlary yok bolsa main productam girayenok")
|
return nil, errors.New("size variantlary yok bolsa main productam girayenok")
|
||||||
} else {
|
} else {
|
||||||
calcPrice(sizeVariants, &mainFlat)
|
calcPrice(sizeVariants, &mainFlat)
|
||||||
|
|
||||||
|
|
@ -487,6 +489,7 @@ func (importer *Importer) importVariant(product models.Product) (*gm.Product, er
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
log.Println(err,"er6")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue