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

**URL:** https://forum.magentochina.org/t/magento2%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AFcoupon-with-the-same-code-already-exists/443
**Category:** Magento 2.X
**Tags:** bug, 错误
**Created:** [2018 年6 月 30 日 16:18 UTC](https://forum.magentochina.org/t/magento2%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AFcoupon-with-the-same-code-already-exists/443 "2018-06-30T16:18:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### 作者： ![Shuai](https://forum.magentochina.org/user_avatar/forum.magentochina.org/shuai/32/3_2.png) [@Shuai](https://forum.magentochina.org/u/Shuai)
#### 发布日期： [2018 年6 月 30 日 16:18 UTC](https://forum.magentochina.org/t/magento2%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AFcoupon-with-the-same-code-already-exists/443/1 "2018-06-30T16:18:33Z")

</div>

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

> **Coupon with the same code already exists.**

![image](https://forum.magentochina.org/uploads/default/original/1X/3a1c9948955a28c4752cb9747b38f67694f3cec2.png)  
翻译过来就是Coupon已存在。开始以为是缓存，各种操作之后都无果。那肯定是这个Coupon是存在于数据库的。  
折腾很久之后解决，分享一下Sql:

> DELETE FROM salesrule\_coupon WHERE rule\_id NOT IN (SELECT rule\_id FROM salesrule WHERE rule\_id is NOT NULL)

 ![image](https://forum.magentochina.org/uploads/default/original/1X/19dc5543a301980142c1887970b3365330d69df6.png)

希望可以帮助到你.

---

<div class="post-metadata">

### 作者： ![25896319](https://forum.magentochina.org/user_avatar/forum.magentochina.org/25896319/32/198_2.png) [@25896319](https://forum.magentochina.org/u/25896319)
#### 发布日期： [2018 年7 月 12 日 08:11 UTC](https://forum.magentochina.org/t/magento2%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AFcoupon-with-the-same-code-already-exists/443/2 "2018-07-12T08:11:11Z")

</div>

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

---

<div class="post-metadata">

### 作者： ![Shuai](https://forum.magentochina.org/user_avatar/forum.magentochina.org/shuai/32/3_2.png) [@Shuai](https://forum.magentochina.org/u/Shuai)
#### 发布日期： [2018 年7 月 12 日 08:46 UTC](https://forum.magentochina.org/t/magento2%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AFcoupon-with-the-same-code-already-exists/443/3 "2018-07-12T08:46:36Z")

</div>

反正是属于是bug了
