• Welcome to KonaKart Community Forum. Please login or sign up.
 

setApplicableProducts - PROMOTIONS

Started by sdyck, August 25, 2009, 07:09:32 pm

Previous topic - Next topic

sdyck

Greetings,

I'm trying to dynamically create a promotion and apply a coupon at the api level and have been having issues trying to add my product to it.

here is a snip of my code:

prom.setStartDate(start);
            prom.setName(promoName);
            // set promotion to last 7 days
            Calendar end = Calendar.getInstance();
            end.add(Calendar.DATE, +7);
            prom.setEndDate(end);
            prom.setActive(true);
            prom.setCumulative(false);
            prom.setRequiresCoupon(true);
            prom.setOrderTotalCode("ot_product_discount");

            // include = 1, exclude = -1, all = 0
            prom.setProductRule(1);

           AdminProduct prod = adminEng.getProduct(sessionId, productIds[0]);
              
           AdminOrderProduct aop = new AdminOrderProduct();
           aop.setProduct(prod);
           prom.setApplicableProducts(new AdminOrderProduct[]{aop});

I am able to get an AdminProduct ok and all seems well, but the product I want to assign to this promotion is not being added (double checked in konanarkadmin front end)

Any example how dynamically creating a promotion with a coupon (I've done this successfully), and then adding only a set of products to it (having troubles here) using the api?


Thanks,

~sdyck

sdyck

Bump .... I'm sure someone knows how to setApplicableProducts for a promotion using the api ... come on guys, HELP

vaibhav1407

Konakart admin application also provides the service in its app lib to add the products to the promotion

1. Create the products first

2. create the promotion

3. Add products to the promotion

adminEng.addProductsToPromotion(adminSessionID, allproductstoadd, promotionId, rule)

adminsessionid - ID of the admin session
allproductstoadd = all admin products that you want to add to the promotion include list  (Thsi is array) for more information see http://www.konakart.com/javadoc/admin/
promotionId = promotion id
rule- Rule 1 == Include -1 = Exclude 0 = all