colorvariantes
This commit is contained in:
parent
0c62b991c6
commit
9ff4c48761
|
|
@ -93,3 +93,12 @@ func IsLCWSizeVariantsAdded(items []models.Variant, keyItem models.Variant) bool
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsImageAdded(images []string, image string) bool {
|
||||||
|
for _, img := range images {
|
||||||
|
if img == image {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
@ -994,7 +994,7 @@ func (importer *Importer) UpdateOrCreateLCW(product models.Product) (instance *I
|
||||||
for _, colorVariant := range *product.ColorVariants {
|
for _, colorVariant := range *product.ColorVariants {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
variant *gm.Product
|
variant gm.Product
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if !colorVariant.IsSellable {
|
if !colorVariant.IsSellable {
|
||||||
|
|
@ -1007,16 +1007,16 @@ func (importer *Importer) UpdateOrCreateLCW(product models.Product) (instance *I
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//todo check parsed import variant
|
//todo check parsed import variant
|
||||||
if variant, err = importer.importVariant(colorVariant); err != nil {
|
if variant, err = importer.importParsedVariant(colorVariant); err != nil {
|
||||||
|
|
||||||
if variant, importer.Error = importer.updateVariant(colorVariant); importer.Error != nil {
|
if variant, importer.Error = importer.updateParsedVariant(colorVariant); importer.Error != nil {
|
||||||
return importer
|
return importer
|
||||||
}
|
}
|
||||||
|
|
||||||
linkedProducts = append(linkedProducts, *variant)
|
linkedProducts = append(linkedProducts, variant)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
newProducts = append(newProducts, *variant)
|
newProducts = append(newProducts, variant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ func NewLCWScraper(link string) LCWScraper {
|
||||||
|
|
||||||
func (s LCWScraper) InitProductDetailParsing() (models.Product, error) {
|
func (s LCWScraper) InitProductDetailParsing() (models.Product, error) {
|
||||||
|
|
||||||
product := models.Product{Vendor: "lcw"}
|
product := models.Product{}
|
||||||
|
|
||||||
// load page with js
|
// load page with js
|
||||||
html, err := loadPage(s.link)
|
html, err := loadPage(s.link)
|
||||||
|
|
@ -45,7 +45,7 @@ func (s LCWScraper) InitProductDetailParsing() (models.Product, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
product = parseDocument(doc, true)
|
product = parseDocument(doc, true)
|
||||||
|
product.Vendor = "lcw"
|
||||||
return product, nil
|
return product, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,8 +237,11 @@ func setupSizeImages(product *models.Product, doc *goquery.Document) {
|
||||||
|
|
||||||
doc.Find("img").Each(func(i int, s *goquery.Selection) {
|
doc.Find("img").Each(func(i int, s *goquery.Selection) {
|
||||||
if image, ok := s.Attr("smallimages"); ok {
|
if image, ok := s.Attr("smallimages"); ok {
|
||||||
|
isAdded := helper.IsImageAdded(product.Images,image)
|
||||||
|
if !isAdded {
|
||||||
product.Images = append(product.Images, image)
|
product.Images = append(product.Images, image)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue