cartitems also entered
This commit is contained in:
parent
7572d41cd4
commit
1d487206da
|
|
@ -152,6 +152,36 @@ func GetFlatSources(db *gorm.DB) ([]ProductAttributeValue, error) {
|
|||
return productSources, nil
|
||||
}
|
||||
|
||||
func GetCartSource(db *gorm.DB) ([]ProductAttributeValue, error) {
|
||||
var wishlistSources []ProductAttributeValue
|
||||
var cartSources []ProductAttributeValue
|
||||
var productSources []ProductAttributeValue
|
||||
|
||||
err := db.Joins("JOIN wishlist wp ON product_attribute_values.product_id = wp.product_id").
|
||||
Joins("JOIN marketplace_products mp ON product_attribute_values.product_id = mp.product_id").
|
||||
Find(&wishlistSources, "mp.marketplace_seller_id=1 AND product_attribute_values.text_value IS NOT NULL AND product_attribute_values.attribute_id=31").Error
|
||||
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
||||
} else {
|
||||
productSources = append(productSources, wishlistSources...)
|
||||
}
|
||||
|
||||
err = db.Joins("JOIN cart_items ci ON product_attribute_values.product_id = ci.product_id").
|
||||
Joins("JOIN marketplace_products mp ON product_attribute_values.product_id = mp.product_id").
|
||||
Find(&cartSources, "mp.marketplace_seller_id=1 AND product_attribute_values.text_value IS NOT NULL AND product_attribute_values.attribute_id=31").Error
|
||||
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
|
||||
} else {
|
||||
productSources = append(productSources, cartSources...)
|
||||
}
|
||||
|
||||
return productSources, nil
|
||||
}
|
||||
|
||||
//func DisableProducts (db *gorm.DB) error {
|
||||
// ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
// defer cancel()
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -82,7 +82,7 @@ func worker(db *gorm.DB, stopCh <-chan struct{}, updatePeriod time.Duration) {
|
|||
return
|
||||
case <-ticker.C:
|
||||
|
||||
result, err := bagisto_models.GetFlatSources(db)
|
||||
result, err := bagisto_models.GetCartSource(db)
|
||||
if err != nil {
|
||||
log.Println("Error retrieving products:", err)
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue