Magento2提示错误Coupon with the same code already exists.

今天客户遇到一个问题,具体的操作是删除一个Coupon之后,然后增加Coupon时系统一直提示:

Coupon with the same code already exists.

image
翻译过来就是Coupon已存在。开始以为是缓存,各种操作之后都无果。那肯定是这个Coupon是存在于数据库的。
折腾很久之后解决,分享一下Sql:

DELETE FROM salesrule_coupon WHERE rule_id NOT IN (SELECT rule_id FROM salesrule WHERE rule_id is NOT NULL)

希望可以帮助到你.

可能是逻辑删除,记录还在数据表中。

反正是属于是bug了