From 4df4a070ec1b5189322a33661eef2be7e1b6dc5a Mon Sep 17 00:00:00 2001 From: merdan Date: Fri, 13 Jan 2023 14:03:56 +0500 Subject: [PATCH] delete only trendyol --- gorm_models/product.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gorm_models/product.go b/gorm_models/product.go index 8fb2e1e..7b95f72 100644 --- a/gorm_models/product.go +++ b/gorm_models/product.go @@ -107,10 +107,10 @@ func DeleteProducts(db *gorm.DB) error { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() //qb := "DELETE FROM products WHERE id NOT IN (select product_id as id from wishlist) AND id NOT IN (select product_id as id from order_items) AND id NOT IN (select parent_id as idfrom order_items);" - qb := "DELETE p FROM products p LEFT JOIN order_items oi ON p.id = oi.product_id LEFT JOIN order_items op ON p.id = op.parent_id WHERE oi.id IS NULL AND op.id IS NULL;" + qb := "DELETE p FROM products p LEFT JOIN order_items oi ON p.id = oi.product_id LEFT JOIN order_items op ON p.id = op.parent_id WHERE oi.id IS NULL AND op.id IS NULL AND product_id IN (SELECT product_id from marketplace_products where marketplace_seller_id=1);" db.WithContext(ctx).Exec(qb) - db.WithContext(ctx).Exec("UPDATE product_flat set sku=concat(id,\"-ordered\"), status=0 where status=1") - db.WithContext(ctx).Exec("UPDATE products set sku=concat(id,\"-ordered\")") + 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)") return db.Error }