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

How can I update Order object

Started by PiotrN, June 27, 2012, 09:58:47 am

Previous topic - Next topic

PiotrN

Hello,

How can I update an Order object from within the server? I have already persisted an Order and I want programmatic change one if its custom fields.

Order order = ... // I already have the proper Order object
order.setCustom1("myCustomValue");

OrderMgr orderMgr = .... // I have access to OrderMgr or KKEng


What method should I invoke to update the order object?
I don't want to create new order nor to update its status - I just want to update its custom fields.

Thanks in advance,
Regards

Pier39

You can try making use of beforeSaveOrder function inside OrderIntegrationMgr.java. This function gets called before an order actually gets saved. You can set custom field values here. This scenario helps if you want to set custom fields while creating order.

Else you could take a look at saveOrder(java.lang.String sessionId, OrderIf order, int languageId) api defined in OrderMgr.

PiotrN

Hi Pier39,

Thanks for your answer!

However, neither the beforeSaveOrder(-) nor saveOrder(-) seems to work for me. Those methods bases on Order that is not persisted in the database (first one) or creates one basing on the OrderIf object (second one).
I am trying to update an existing order - not to persist another one.

Regards.

Pier39

I think this will help you,


KKCriteria updateC = getNewCriteria();
KKCriteria selectC = getNewCriteria();
updateC.addForInsert(BaseOrdersPeer.CUSTOM1, "VALUE");
updateC.addForInsert(BaseOrdersPeer.CUSTOM2, "VALUE");
updateC.addForInsert(BaseOrdersPeer.CUSTOM3, "VALUE");
selectC.add(BaseOrdersPeer.ORDERS_ID, order.getId());
BasePeer.doUpdate(selectC, updateC);

PiotrN

Aaaah, you're a gentleman and a scholar.

Thanks a lot mate, it works like a charm!