cat bug fix
This commit is contained in:
parent
ba79d67ab3
commit
4732a0ce84
|
|
@ -106,15 +106,15 @@ func StartImport(w http.ResponseWriter, route *http.Request) {
|
||||||
mainImportWG.Add(len(mainCategories))
|
mainImportWG.Add(len(mainCategories))
|
||||||
|
|
||||||
log.Println("Start Product delete")
|
log.Println("Start Product delete")
|
||||||
//delete := time.Now()
|
delete := time.Now()
|
||||||
//errDel := gm.DeleteProducts(baza)
|
errDel := gm.DeleteProducts(baza)
|
||||||
//deleteElapsed := time.Since(delete)
|
deleteElapsed := time.Since(delete)
|
||||||
//log.Printf("Delete products took %s", deleteElapsed)
|
log.Printf("Delete products took %s", deleteElapsed)
|
||||||
//
|
|
||||||
//if errDel != nil {
|
if errDel != nil {
|
||||||
// http.Error(w, errDel.Error(), http.StatusInternalServerError)
|
http.Error(w, errDel.Error(), http.StatusInternalServerError)
|
||||||
// return
|
return
|
||||||
//}
|
}
|
||||||
|
|
||||||
for _, element := range mainCategories {
|
for _, element := range mainCategories {
|
||||||
slug := element.Translations[0].Slug
|
slug := element.Translations[0].Slug
|
||||||
|
|
@ -215,29 +215,11 @@ func getCats(db *gorm.DB, catIDs []int) ([3]gm.Category, string, error) {
|
||||||
var categories [3]gm.Category
|
var categories [3]gm.Category
|
||||||
var keywords string
|
var keywords string
|
||||||
|
|
||||||
if len(mainCategories) > 0 {
|
if errCat := db.Preload("Translations").Find(&categories, catIDs).Error; errCat != nil {
|
||||||
for index, id := range catIDs {
|
|
||||||
for _, item := range mainCategories {
|
|
||||||
if item.ID == uint(id) {
|
|
||||||
categories[index] = item
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
errCat := db.Preload("Translations").Find(&categories, catIDs).Error
|
|
||||||
|
|
||||||
if errCat != nil {
|
|
||||||
log.Println(errCat)
|
log.Println(errCat)
|
||||||
return categories, keywords, errCat
|
return categories, keywords, errCat
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println(categories)
|
|
||||||
|
|
||||||
for _, cat := range categories {
|
for _, cat := range categories {
|
||||||
if len(cat.Translations) > 0 && cat.Translations[0].MetaKeywords != "" {
|
if len(cat.Translations) > 0 && cat.Translations[0].MetaKeywords != "" {
|
||||||
translation := cat.Translations[0]
|
translation := cat.Translations[0]
|
||||||
|
|
@ -258,8 +240,6 @@ func ImportProduct(product models.Product, db *gorm.DB) error {
|
||||||
|
|
||||||
categories, keywords, errCat := getCats(&tx, product.Categories)
|
categories, keywords, errCat := getCats(&tx, product.Categories)
|
||||||
|
|
||||||
return tx.Rollback().Error
|
|
||||||
|
|
||||||
if errCat != nil {
|
if errCat != nil {
|
||||||
log.Println("ERR0 Categories" + errCat.Error())
|
log.Println("ERR0 Categories" + errCat.Error())
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue