fix
This commit is contained in:
parent
ba6a042174
commit
59e191fb82
|
|
@ -216,13 +216,16 @@ func getCats(db *gorm.DB, catIDs []int) ([]gm.Category, string, error) {
|
|||
var keywords string
|
||||
|
||||
if len(mainCategories) > 0 {
|
||||
for _, item := range mainCategories {
|
||||
for _, id := range catIDs {
|
||||
for _, id := range catIDs {
|
||||
for _, item := range mainCategories {
|
||||
if item.ID == uint(id) {
|
||||
categories = append(categories, item)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
errCat := db.Preload("Translations").Find(&categories, catIDs).Error
|
||||
|
||||
|
|
@ -239,6 +242,7 @@ func getCats(db *gorm.DB, catIDs []int) ([]gm.Category, string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
log.Println(catIDs, categories)
|
||||
return categories, keywords, nil
|
||||
}
|
||||
|
||||
|
|
@ -246,10 +250,11 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
|||
|
||||
famAndSellerWG.Wait() //wait until attribute families and sellers are not get from mysql
|
||||
//BEGIN TRANSACTION
|
||||
return nil
|
||||
tx := *db.Begin()
|
||||
|
||||
categories, keywords, errCat := getCats(&tx, product.Categories)
|
||||
log.Println(categories)
|
||||
|
||||
if errCat != nil {
|
||||
log.Println("ERR0 Categories" + errCat.Error())
|
||||
tx.Rollback()
|
||||
|
|
|
|||
Loading…
Reference in New Issue