diff --git a/gorm_models/product.go b/gorm_models/product.go index fabcde1..69cb85a 100644 --- a/gorm_models/product.go +++ b/gorm_models/product.go @@ -107,8 +107,8 @@ func DeleteProducts(db *gorm.DB) error { //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;" db.WithContext(ctx).Exec(qb) - db.WithContext(ctx).Exec("UPDATE product_flat set sku=concat(sku,\"-ordered\"), status=0") - db.WithContext(ctx).Exec("UPDATE products set sku=concat(sku,\"-ordered\")") + 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\")") return db.Error }