I deleted a promotion and its coupons persisted. I created a new promotion and re-used the coupon code and received errors loading my promotion. Which lead to discovery of #2855836: Coupon codes need unique value validation constraint.

Comments

mglaman created an issue. See original summary.

vasike’s picture

Assigned: Unassigned » vasike

i'll try this

vasike’s picture

Status: Active » Needs review

There is a PR about this
https://github.com/drupalcommerce/commerce/pull/658

- Similar with what we have for Product & Variations and Order & Items
- Also a post update to delete the orphaned coupons.
- Nothing on tests - not sure

This issue raises some questions:

1. Do we need a backreference field for promotion on coupons
similar with what's done at #2557477: Add line item -> order and product variation -> product backreferences
Also new methods getPromotion / getPromotionId

2. What about new method on Promotion entity:
getCoupons() / getCouponsCodes / getCouponsIds

3. ....

mglaman’s picture

1. Do we need a backreference field for promotion on coupons

Yes, I thought I made a ticket for this, I guess not.

2. What about new method on Promotion entity:
getCoupons() / getCouponsCodes / getCouponsIds

Yes.

Want to make of those two issues?

vasike’s picture

Status: Needs review » Needs work
Related issues: +#2857560: Complete the coupon <-> promotion data model

This is part of #2857560: Complete the coupon <-> promotion data model for PR
After i'll publish the new PR, i'll close the one i did previously.

vasike’s picture

Status: Needs work » Needs review

new PR for the parent issue, it includes the fix for this.
https://github.com/drupalcommerce/commerce/pull/660

bojanz’s picture

Status: Needs review » Closed (duplicate)

Closing for the parent issue.