Browse Source

Fix shop actions

Vova Tkach 5 years ago
parent
commit
7ebfd5a641

+ 2 - 2
modules/module_shop_act_delete.go

@@ -23,10 +23,10 @@ func (this *Modules) RegisterAction_ShopDelete() *Action {
 			if _, err := tx.Exec("SELECT id FROM shop_products WHERE id = ? FOR UPDATE;", pf_id); err != nil {
 				return err
 			}
-			if _, err := tx.Exec("SELECT id FROM shop_cat_product_rel WHERE product_id = ? FOR UPDATE;", pf_id); err != nil {
+			if _, err := tx.Exec("SELECT product_id FROM shop_cat_product_rel WHERE product_id = ? FOR UPDATE;", pf_id); err != nil {
 				return err
 			}
-			if _, err := tx.Exec("SELECT id FROM shop_filter_product_values WHERE product_id = ? FOR UPDATE;", pf_id); err != nil {
+			if _, err := tx.Exec("SELECT product_id FROM shop_filter_product_values WHERE product_id = ? FOR UPDATE;", pf_id); err != nil {
 				return err
 			}
 

+ 6 - 6
modules/module_shop_act_modify.go

@@ -131,10 +131,10 @@ func (this *Modules) RegisterAction_ShopModify() *Action {
 					}
 					var bulkInsertArr []string
 					for _, el := range catids {
-						bulkInsertArr = append(bulkInsertArr, `(NULL,`+utils.Int64ToStr(lastID)+`,`+utils.IntToStr(el)+`)`)
+						bulkInsertArr = append(bulkInsertArr, `(`+utils.Int64ToStr(lastID)+`,`+utils.IntToStr(el)+`)`)
 					}
 					if _, err = tx.Exec(
-						`INSERT INTO shop_cat_product_rel (id,product_id,category_id) VALUES ` + strings.Join(bulkInsertArr, ",") + `;`,
+						`INSERT INTO shop_cat_product_rel (product_id,category_id) VALUES ` + strings.Join(bulkInsertArr, ",") + `;`,
 					); err != nil {
 						return err
 					}
@@ -169,10 +169,10 @@ func (this *Modules) RegisterAction_ShopModify() *Action {
 				if _, err := tx.Exec("SELECT id FROM shop_currencies WHERE id = ? FOR UPDATE;", utils.StrToInt(pf_currency)); err != nil {
 					return err
 				}
-				if _, err := tx.Exec("SELECT id FROM shop_cat_product_rel WHERE product_id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
+				if _, err := tx.Exec("SELECT product_id FROM shop_cat_product_rel WHERE product_id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err
 				}
-				if _, err := tx.Exec("SELECT id FROM shop_filter_product_values WHERE product_id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
+				if _, err := tx.Exec("SELECT product_id FROM shop_filter_product_values WHERE product_id = ? FOR UPDATE;", utils.StrToInt(pf_id)); err != nil {
 					return err
 				}
 
@@ -229,10 +229,10 @@ func (this *Modules) RegisterAction_ShopModify() *Action {
 					}
 					var bulkInsertArr []string
 					for _, el := range catids {
-						bulkInsertArr = append(bulkInsertArr, `(NULL,`+pf_id+`,`+utils.IntToStr(el)+`)`)
+						bulkInsertArr = append(bulkInsertArr, `(`+pf_id+`,`+utils.IntToStr(el)+`)`)
 					}
 					if _, err := tx.Exec(
-						`INSERT INTO shop_cat_product_rel (id,product_id,category_id) VALUES ` + strings.Join(bulkInsertArr, ",") + `;`,
+						`INSERT INTO shop_cat_product_rel (product_id,category_id) VALUES ` + strings.Join(bulkInsertArr, ",") + `;`,
 					); err != nil {
 						return err
 					}

+ 1 - 1
modules/module_shop_attributes_act_delete.go

@@ -28,7 +28,7 @@ func (this *Modules) RegisterAction_ShopAttributesDelete() *Action {
 			}
 			if _, err := tx.Exec(
 				`SELECT
-					shop_filter_product_values.id
+					shop_filter_product_values.product_id
 				FROM
 					shop_filter_product_values
 					LEFT JOIN shop_filters_values ON shop_filters_values.id = shop_filter_product_values.filter_value_id

+ 1 - 1
modules/module_shop_attributes_act_modify.go

@@ -101,7 +101,7 @@ func (this *Modules) RegisterAction_ShopAttributesModify() *Action {
 				}
 				if _, err := tx.Exec(
 					`SELECT
-						shop_filter_product_values.id
+						shop_filter_product_values.product_id
 					FROM
 						shop_filter_product_values
 						LEFT JOIN shop_filters_values ON shop_filters_values.id = shop_filter_product_values.filter_value_id

+ 1 - 1
modules/module_shop_categories_act_delete.go

@@ -23,7 +23,7 @@ func (this *Modules) RegisterAction_ShopCategoriesDelete() *Action {
 			if _, err := tx.Exec("SELECT id FROM shop_cats FOR UPDATE;"); err != nil {
 				return err
 			}
-			if _, err := tx.Exec("SELECT id FROM shop_cat_product_rel WHERE category_id = ? FOR UPDATE;", pf_id); err != nil {
+			if _, err := tx.Exec("SELECT category_id FROM shop_cat_product_rel WHERE category_id = ? FOR UPDATE;", pf_id); err != nil {
 				return err
 			}