1 Reply Latest reply: Sep 16, 2013 8:00 AM by SubbaraoD RSS

    ATG UpdateOrder best pratices

    PrincessPoonam

      Hi All,

       

        If i have extended CartModifierFormHandler, and have added custom code in the handleAddItemToOrder() method.

       

      1) Should i add Transaction and synchronized blocks again in the extended class if i am calling preAdditem,updateOrder(getOrder()), setCatalogRefIds, post etc.....

      2) What are the things to keep in mind when extending OOTB CartModifierFormHandler and handle methods and updating order etc...

       

       

      Regrads

        • 1. Re: ATG UpdateOrder best pratices
          SubbaraoD

          Hi Bravo,

           

          OOB handleAddItemToOrder() creates transaction before calling preAdditem(), updateOrder(), postAddItem(). If you are overriding only preAdditem(),postAddItem() methods no need to create transaction again. But if you override handleAddItemToOrder() completely then Yes, you need to add transaction & synchronised blocks.

           

          Whenever you are modifying order you should follow below steps. Otherwise you will get concurrent

           

          1. Begin Transaction  - ensureTransaction()
          2. Synchronize on Order object
          3. Perform ALL modifications to the order object.
          4. Call OrderManager.updateOrder()
          5. End Synchronization
          6. End Transaction.