kategoria tekst
This commit is contained in:
parent
63591d6628
commit
979a41e13e
|
|
@ -247,8 +247,10 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
categories, keywords, errCat := getCats(db, product.Categories)
|
categories, keywords, errCat := getCats(db, product.Categories)
|
||||||
|
|
||||||
if errCat != nil {
|
if errCat != nil {
|
||||||
//log.Println("ERR0001"+errCat.Error())
|
log.Println("ERR0001" + errCat.Error())
|
||||||
return errCat
|
return errCat
|
||||||
|
} else {
|
||||||
|
log.Println(categories)
|
||||||
}
|
}
|
||||||
|
|
||||||
var brand gm.Brand
|
var brand gm.Brand
|
||||||
|
|
@ -311,7 +313,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
tx := db.Begin()
|
tx := db.Begin()
|
||||||
|
|
||||||
if errMainProduct := tx.Omit("Categories.*", "SuperAttributes.*", "ParentID").Create(&iproduct).Error; errMainProduct != nil {
|
if errMainProduct := tx.Omit("Categories.*", "SuperAttributes.*", "ParentID").Create(&iproduct).Error; errMainProduct != nil {
|
||||||
//log.Println("ERR1" + errMainProduct.Error())
|
log.Println("ERR1" + errMainProduct.Error())
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return errMainProduct
|
return errMainProduct
|
||||||
}
|
}
|
||||||
|
|
@ -322,7 +324,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
|
|
||||||
if errProductMainFlat := tx.Create(&mainProductFlat).Error; errProductMainFlat != nil {
|
if errProductMainFlat := tx.Create(&mainProductFlat).Error; errProductMainFlat != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
//log.Println("ERR2" + errProductMainFlat.Error())
|
log.Println("ERR2" + errProductMainFlat.Error())
|
||||||
return errProductMainFlat
|
return errProductMainFlat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,7 +364,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errProdVariant := tx.Omit("Categories.*").Create(&productVariant).Error; errProdVariant != nil {
|
if errProdVariant := tx.Omit("Categories.*").Create(&productVariant).Error; errProdVariant != nil {
|
||||||
//log.Println("ERR3" + errProdVariant.Error())
|
log.Println("ERR3" + errProdVariant.Error())
|
||||||
tx.RollbackTo(savePoint)
|
tx.RollbackTo(savePoint)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -429,7 +431,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
|
|
||||||
if attError := tx.Create(&attributes).Error; attError != nil {
|
if attError := tx.Create(&attributes).Error; attError != nil {
|
||||||
tx.RollbackTo(savePoint)
|
tx.RollbackTo(savePoint)
|
||||||
//log.Println("ERR4" + attError.Error())
|
log.Println("ERR4" + attError.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,7 +444,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errVariant := tx.Create(&flatVariant).Error; errVariant != nil {
|
if errVariant := tx.Create(&flatVariant).Error; errVariant != nil {
|
||||||
//log.Println("ERR5" + errVariant.Error())
|
log.Println("ERR5" + errVariant.Error())
|
||||||
tx.RollbackTo(savePoint)
|
tx.RollbackTo(savePoint)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -482,7 +484,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errProdVariant := tx.Omit("Categories.*").Create(&productVariant).Error; errProdVariant != nil {
|
if errProdVariant := tx.Omit("Categories.*").Create(&productVariant).Error; errProdVariant != nil {
|
||||||
//log.Println("ERR5" + errProdVariant.Error())
|
log.Println("ERR5" + errProdVariant.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,7 +495,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
variantFlat.ParentID = mainProductFlat.ID
|
variantFlat.ParentID = mainProductFlat.ID
|
||||||
|
|
||||||
if errVariant := tx.Create(&variantFlat).Error; errVariant != nil {
|
if errVariant := tx.Create(&variantFlat).Error; errVariant != nil {
|
||||||
//log.Println("ERR6" + errVariant.Error())
|
log.Println("ERR6" + errVariant.Error())
|
||||||
tx.RollbackTo(colorSavePoint)
|
tx.RollbackTo(colorSavePoint)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -601,14 +603,14 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errSizeVar := tx.Omit("Categories.*").Create(&sizeVariantProduct).Error; errSizeVar != nil {
|
if errSizeVar := tx.Omit("Categories.*").Create(&sizeVariantProduct).Error; errSizeVar != nil {
|
||||||
//log.Println("ERR7" + errSizeVar.Error())
|
log.Println("ERR7" + errSizeVar.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
flatVariant.ProductID = sizeVariantProduct.ID
|
flatVariant.ProductID = sizeVariantProduct.ID
|
||||||
|
|
||||||
if errVariant := tx.Create(&flatVariant).Error; errVariant != nil {
|
if errVariant := tx.Create(&flatVariant).Error; errVariant != nil {
|
||||||
//log.Println("ERR8" + errVariant.Error())
|
log.Println("ERR8" + errVariant.Error())
|
||||||
tx.RollbackTo(sizeSavePoint)
|
tx.RollbackTo(sizeSavePoint)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -630,7 +632,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if errFlat != nil {
|
if errFlat != nil {
|
||||||
//log.Println("ERR9" + errFlat.Error())
|
log.Println("ERR9" + errFlat.Error())
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return errFlat
|
return errFlat
|
||||||
}
|
}
|
||||||
|
|
@ -640,7 +642,7 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
errSProduct := tx.Create(&sProduct).Error
|
errSProduct := tx.Create(&sProduct).Error
|
||||||
|
|
||||||
if errSProduct != nil {
|
if errSProduct != nil {
|
||||||
//log.Println("ERR10" + errSProduct.Error())
|
log.Println("ERR10" + errSProduct.Error())
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return errSProduct
|
return errSProduct
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue