| Author |
Problem with OrderCopy Command
|
|
|
| Hi
We have just migrated our application from WCS 5.1 to WC 5.6. We are facing problem at a certain piece of code in our application. This piece of code uses the OrderCopy command to create a copy of an already existing order. Before calling the OrderCopy co
mmand, the application code sets the status of fromOrderId to 'C' and then calls the OrderCopy command but what we are seeing is that even though the status of this order is 'C' before the command execution, the moment OrderCopy command passes its executi
on to OrderItemUpdateCmd, the status of the fromOrderId is back to 'P'. This problem is only happening in the new system (WC 5.6). The same piece of code works fine in WCS 5.1
Does anyone know why this status change takes place? Is OrderCopy command or any command called from OrderCopy changes the status of the order.
Thanks in advance for your suggestions and help.
Niranjan Soni
| |
|
| Hello All
I am not sure whether my earlier post is explaining the problem clearly so i am going to try again. System is migrated from 5.1 to 5.6. There is a piece of code in the application that uses OrderCopy command to create a copy of an already existing order.
This piece of code works fine in 5.1 but is not working correctly in 5.6.
The failing piece of code is doing the following
1. Takes the already existing order and orderitems and changes their status of order and orderitems from P to C
2. Then calls OrderCopy command to create a copy of the order. The OrderCopy command seems to execute fine and it is calling OrderItemUpdateCmd.
3. In our application we have overidden OrderItemUpdateCmd command which provide the same functionality as the 5.1 OrderItemUpdateCmd but as well adds some custom bit required for our application. One piece of check in this OrderItemUpdateCmd is that befo
re creating a new entry in the order table it checks whether there is an order existing pending order (status P) for this user.
4. What is happening in our 5.6 migrated application is that even though the application is changing the status of the order from P to C before calling OrderCopy, when the check for existing pending order is performed by OrderItemUpdateCmd it is finding a
pending order for that user. This means that somehow or somewhere the status for the Order is not getting changed to C or if it is getting changed then somehow during the call to OrderCopy this status is getting changed from C to back to P.
What i am not able to understand or figure out why and where it is happening and i am using CommitCopyHelper after changing the status of the order to C in my application. So this is becoming really strange and a great mystery for me.
Anyone got any ideas??
Thanks
Niranjan
| |
| Robert Brown 2005-12-11, 5:56 pm |
| > Hello All
>
> I am not sure whether my earlier post is explaining the problem clearly so i am going to try again. System is migrated from 5.1 to 5.6. There is a piece of code in the application that uses OrderCopy command to create a copy of an already existing order
. This piece of code works fine in 5.1 but is not working correctly in 5.6.
>
> The failing piece of code is doing the following
>
> 1. Takes the already existing order and orderitems and changes their status of order and orderitems from P to C
> 2. Then calls OrderCopy command to create a copy of the order. The OrderCopy command seems to execute fine and it is calling OrderItemUpdateCmd.
> 3. In our application we have overidden OrderItemUpdateCmd command which provide the same functionality as the 5.1 OrderItemUpdateCmd but as well adds some custom bit required for our application. One piece of check in this OrderItemUpdateCmd is that be
fore creating a new entry in the order table it checks whether there is an order existing pending order (status P) for this user.
> 4. What is happening in our 5.6 migrated application is that even though the application is changing the status of the order from P to C before calling OrderCopy, when the check for existing pending order is performed by OrderItemUpdateCmd it is finding
a pending order for that user. This means that somehow or somewhere the status for the Order is not getting changed to C or if it is getting changed then somehow during the call to OrderCopy this status is getting changed from C to back to P.
>
> What i am not able to understand or figure out why and where it is happening and i am using CommitCopyHelper after changing the status of the order to C in my application. So this is becoming really strange and a great mystery for me.
>
> Anyone got any ideas??
Well, I'm not sure what changed in the OrderCopy command between v5.1
and v5.6 but I have a suggestion to correct the behavior. Since you
have customized the OrderItemUpdateCmdImpl already why don't you simply
add an if statement to check the calling command and skip the custom
code if the it is OrderCopy. Otherwise, the else block would continue
to check for the P status as usual. Just a thought...
R
| |
|
| Hi Robert
Thanks for the suggestion, i will try that but can you tell how can i find out which is the calling command i.e. if you can provide me the exact syntax .
Niranjan
| |
| Robert Brown 2005-12-12, 6:04 pm |
| > Hi Robert
>
> Thanks for the suggestion, i will try that but can you tell how can i find out which is the calling command i.e. if you can provide me the exact syntax .
I can't recall exactly (and don't have time to test right now) but look
at the CommandContext available from the Web Controller. There are
methods for getCurrentCommandName() (which should return your
OrderItemUpdate custom command) and getCommandName() (which might return
the calling command OrderCopy) if memory serves.
Determine with this untested code...
CommandContext cmdCtx = (CommandContext)
request.getAttribute(ECConstants.EC_COMMANDCONTEXT);
System.out.println ("getCurrentCommandName() = " +
cmdCtx.getCurrentCommandName());
System.out.println ("getCommandName() = " + cmdCtx.getCommandName());
You'll need to import com.ibm.commerce.command.* of course (which should
be there always).
R
|
|
|
|