Browse Source

Fix attributes update action

Vova Tkach 5 years ago
parent
commit
19dde439af
1 changed files with 21 additions and 0 deletions
  1. 21 0
      modules/module_shop_attributes_act_modify.go

+ 21 - 0
modules/module_shop_attributes_act_modify.go

@@ -158,6 +158,27 @@ func (this *Modules) RegisterAction_ShopAttributesModify() *Action {
 					); err != nil {
 						return err
 					}
+				} else {
+					if _, err := tx.Exec(
+						`DELETE
+							shop_filter_product_values
+						FROM
+							shop_filter_product_values
+							LEFT JOIN shop_filters_values ON shop_filters_values.id = shop_filter_product_values.filter_value_id
+						WHERE
+							shop_filters_values.id IS NOT NULL AND
+							shop_filters_values.filter_id = ?
+						;`,
+						utils.StrToInt(pf_id),
+					); err != nil {
+						return err
+					}
+					if _, err := tx.Exec(
+						`DELETE FROM shop_filters_values WHERE filter_id = ?;`,
+						utils.StrToInt(pf_id),
+					); err != nil {
+						return err
+					}
 				}
 
 				// Insert new values, update existed rows