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
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
var (
|
||||
variant *gm.Product
|
||||
variant gm.Product
|
||||
err error
|
||||
)
|
||||
if !colorVariant.IsSellable {
|
||||
|
|
@ -1007,16 +1007,16 @@ func (importer *Importer) UpdateOrCreateLCW(product models.Product) (instance *I
|
|||
} else {
|
||||
|
||||
//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
|
||||
}
|
||||
|
||||
linkedProducts = append(linkedProducts, *variant)
|
||||
linkedProducts = append(linkedProducts, variant)
|
||||
|
||||
} 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) {
|
||||
|
||||
product := models.Product{Vendor: "lcw"}
|
||||
product := models.Product{}
|
||||
|
||||
// load page with js
|
||||
html, err := loadPage(s.link)
|
||||
|
|
@ -45,7 +45,7 @@ func (s LCWScraper) InitProductDetailParsing() (models.Product, error) {
|
|||
}
|
||||
|
||||
product = parseDocument(doc, true)
|
||||
|
||||
product.Vendor = "lcw"
|
||||
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) {
|
||||
if image, ok := s.Attr("smallimages"); ok {
|
||||
isAdded := helper.IsImageAdded(product.Images,image)
|
||||
if !isAdded {
|
||||
product.Images = append(product.Images, image)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue