test
This commit is contained in:
parent
2664fd7275
commit
ba79d67ab3
|
|
@ -211,17 +211,15 @@ func getTotalDocumentCount(db string) int {
|
||||||
// todo defailt variant
|
// todo defailt variant
|
||||||
// productflat
|
// productflat
|
||||||
|
|
||||||
func getCats(db *gorm.DB, catIDs []int) ([]gm.Category, string, error) {
|
func getCats(db *gorm.DB, catIDs []int) ([3]gm.Category, string, error) {
|
||||||
var categories []gm.Category
|
var categories [3]gm.Category
|
||||||
var keywords string
|
var keywords string
|
||||||
|
|
||||||
log.Println(catIDs)
|
|
||||||
|
|
||||||
if len(mainCategories) > 0 {
|
if len(mainCategories) > 0 {
|
||||||
for _, id := range catIDs {
|
for index, id := range catIDs {
|
||||||
for _, item := range mainCategories {
|
for _, item := range mainCategories {
|
||||||
if item.ID == uint(id) {
|
if item.ID == uint(id) {
|
||||||
categories = append(categories, item)
|
categories[index] = item
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -238,6 +236,8 @@ func getCats(db *gorm.DB, catIDs []int) ([]gm.Category, string, error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
@ -246,7 +246,6 @@ func getCats(db *gorm.DB, catIDs []int) ([]gm.Category, string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(categories)
|
|
||||||
return categories, keywords, nil
|
return categories, keywords, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ type Brand struct {
|
||||||
Name string `gorm:"default:TESTBRAND"`
|
Name string `gorm:"default:TESTBRAND"`
|
||||||
Code string
|
Code string
|
||||||
Status bool
|
Status bool
|
||||||
Categories []Category `gorm:"many2many:category_brands;"`
|
Categories [3]Category `gorm:"many2many:category_brands;"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindOrCreateBrand(db *gorm.DB, brand string, categories []Category) (Brand, error) {
|
func FindOrCreateBrand(db *gorm.DB, brand string, categories [3]Category) (Brand, error) {
|
||||||
|
|
||||||
var brandObject Brand
|
var brandObject Brand
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ type Product struct {
|
||||||
BrandID uint `sql:"DEFAULT:NULL"`
|
BrandID uint `sql:"DEFAULT:NULL"`
|
||||||
Brand Brand
|
Brand Brand
|
||||||
Images []ProductImage
|
Images []ProductImage
|
||||||
Categories []Category `gorm:"many2many:product_categories;"`
|
Categories [3]Category `gorm:"many2many:product_categories;"`
|
||||||
AttributeValues []ProductAttributeValue
|
AttributeValues []ProductAttributeValue
|
||||||
SuperAttributes []Attribute `gorm:"many2many:product_super_attributes;"`
|
SuperAttributes []Attribute `gorm:"many2many:product_super_attributes;"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue