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