Kentico 10 Discount coupon product relationship

Michael K asked on February 16, 2018 18:31

Hi guys, I am trying to find a list of all products associated with a coupon and can't seem to find any API for doing that.

I've got the coupon.DiscountCouponIsExcluded flag. So if that's false, it means that the option ticked is "Only The Following Products". And I want to basically list all the products that can be associated with that coupon.

It seems like I can only grab the product-coupon (singular) relationship with SKUDIscountCouponInfo class. But then my condition is , if there's no relationship BUT the "Only The Following Products" list is empty , I still want to allow the coupon to be applied to any products. But can't check if that "Only The Following Products" is empty or not....

Please advise....

Recent Answers

David te Kloese answered on February 19, 2018 15:20


Kentico stores the skus in different tables.

Check the following SQL tables to find the info:

select * from COM_MultiBuyCouponCode -- will give you the MultiBuyDiscountID from the CouponCode itself 
select * from COM_MultiBuyDiscount where MultiBuyDiscountID = [X] -- all info on the Discount
select * from COM_MultiBuyDiscountSKU where MultiBuyDiscountID = [X] -- all sku's related to your discount

The following code should get you started:

    int myDiscountID = MultiBuyCouponCodeInfoProvider.GetMultiBuyCouponCodeInfo(yourCouponGuid)

    var skus = MultiBuyDiscountSKUInfoProvider.GetMultiBuyDiscountSKUs()
    .WhereEquals("MultiBuyDiscountID", myDiscountID);
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.