colorvariantes
This commit is contained in:
parent
9ff4c48761
commit
21f1bd133a
|
|
@ -112,11 +112,12 @@ func DeleteProducts(db *gorm.DB) error {
|
||||||
"LEFT JOIN order_items oi ON p.id = oi.product_id " +
|
"LEFT JOIN order_items oi ON p.id = oi.product_id " +
|
||||||
"LEFT JOIN order_items op ON p.id = op.parent_id " +
|
"LEFT JOIN order_items op ON p.id = op.parent_id " +
|
||||||
"LEFT JOIN wishlist wp ON p.id = wp.product_id " +
|
"LEFT JOIN wishlist wp ON p.id = wp.product_id " +
|
||||||
|
"LEFT JOIN wishlist wl ON wl.product_id = p.parent_id " +
|
||||||
"JOIN marketplace_products mp ON p.id = mp.product_id "+
|
"JOIN marketplace_products mp ON p.id = mp.product_id "+
|
||||||
"WHERE oi.id IS NULL AND op.id IS NULL AND wp.id IS NULL AND mp.marketplace_seller_id=1;"
|
"WHERE oi.id IS NULL AND op.id IS NULL AND wp.id IS NULL AND wl.id IS NULL AND mp.marketplace_seller_id=1;"
|
||||||
db.WithContext(ctx).Exec(qb)
|
db.WithContext(ctx).Exec(qb)
|
||||||
db.WithContext(ctx).Exec("UPDATE product_flat set sku=concat(id,\"-ordered\"), status=0 where status=1 AND product_id IN (SELECT product_id from marketplace_products where marketplace_seller_id=1)" )
|
//db.WithContext(ctx).Exec("UPDATE product_flat set sku=concat(id,\"-ordered\"), status=0 where status=1 AND product_id IN (SELECT product_id from marketplace_products where marketplace_seller_id=1)" )
|
||||||
db.WithContext(ctx).Exec("UPDATE products set sku=concat(id,\"-ordered\") WHERE id IN (SELECT product_id from marketplace_products where marketplace_seller_id=1)")
|
//db.WithContext(ctx).Exec("UPDATE products set sku=concat(id,\"-ordered\") WHERE id IN (SELECT product_id from marketplace_products where marketplace_seller_id=1)")
|
||||||
return db.Error
|
return db.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ type Importer struct {
|
||||||
baza *gorm.DB
|
baza *gorm.DB
|
||||||
families []gm.AttributeFamily
|
families []gm.AttributeFamily
|
||||||
sellers map[string]gm.MarketplaceSeller
|
sellers map[string]gm.MarketplaceSeller
|
||||||
wishlist map[string]gm.Product
|
//wishlist map[string]gm.Product
|
||||||
AttributesMap map[string]gm.Attribute
|
AttributesMap map[string]gm.Attribute
|
||||||
Error error
|
Error error
|
||||||
ImportWGroup sync.WaitGroup
|
ImportWGroup sync.WaitGroup
|
||||||
|
|
@ -46,7 +46,7 @@ func ImporterInstance() (instance *Importer, err error) {
|
||||||
|
|
||||||
instance = &Importer{baza: db}
|
instance = &Importer{baza: db}
|
||||||
|
|
||||||
instance.ImportWGroup.Add(5)
|
instance.ImportWGroup.Add(4)
|
||||||
|
|
||||||
//load main categories to memory
|
//load main categories to memory
|
||||||
go func(db *gorm.DB) {
|
go func(db *gorm.DB) {
|
||||||
|
|
@ -119,22 +119,22 @@ func ImporterInstance() (instance *Importer, err error) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//load wishlist to memory
|
//load wishlist to memory
|
||||||
go func(){
|
//go func(){
|
||||||
defer instance.ImportWGroup.Done()
|
// defer instance.ImportWGroup.Done()
|
||||||
|
//
|
||||||
var wishlist, err = gm.GetWishlistProducts(db)
|
// var wishlist, err = gm.GetWishlistProducts(db)
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
instance.Error = err
|
// instance.Error = err
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
instance.wishlist = make(map[string]gm.Product, len(wishlist))
|
// instance.wishlist = make(map[string]gm.Product, len(wishlist))
|
||||||
|
//
|
||||||
for _, product := range wishlist {
|
// for _, product := range wishlist {
|
||||||
instance.wishlist[product.Sku] = product
|
// instance.wishlist[product.Sku] = product
|
||||||
}
|
// }
|
||||||
}()
|
//}()
|
||||||
|
|
||||||
if instance.Error != nil {
|
if instance.Error != nil {
|
||||||
log.Println(instance.Error)
|
log.Println(instance.Error)
|
||||||
|
|
@ -371,10 +371,10 @@ func (importer *Importer) ImportProduct(product models.Product) (instance *Impor
|
||||||
func (importer *Importer) importVariant(product models.Product) (*gm.Product, error) {
|
func (importer *Importer) importVariant(product models.Product) (*gm.Product, error) {
|
||||||
|
|
||||||
// check if wishlisted then update if.
|
// check if wishlisted then update if.
|
||||||
if _, ok := importer.wishlist[product.ProductNumber]; ok {
|
//if _, ok := importer.wishlist[product.ProductNumber]; ok {
|
||||||
delete(importer.wishlist,product.ProductNumber)
|
// delete(importer.wishlist,product.ProductNumber)
|
||||||
return importer.updateVariant(product)
|
// return importer.updateVariant(product)
|
||||||
}
|
//}
|
||||||
|
|
||||||
productRepo := InitProductRepo(&product, importer.GetColorOption(product.Color), importer.GetSexOption(product.Cinsiyet))
|
productRepo := InitProductRepo(&product, importer.GetColorOption(product.Color), importer.GetSexOption(product.Cinsiyet))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue