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