Problem solved, it's a bug in method excute of MergeCartProcessorImpl :
Code: Select all
public void execute(WebRequest request, Authentication authResult) {
Customer loggedInCustomer = customerService.readCustomerByUsername(authResult.getName());
//Here
Customer anonymousCustomer = (Customer) request.getAttribute(CustomerStateRequestProcessor.ANONYMOUS_CUSTOMER_SESSION_ATTRIBUTE_NAME, WebRequest.SCOPE_GLOBAL_SESSION);
Order cart = null;
if (anonymousCustomer != null) {
cart = orderService.findCartForCustomer(anonymousCustomer);
}
MergeCartResponse mergeCartResponse;
try {
mergeCartResponse = mergeCartService.mergeCart(loggedInCustomer, cart);
} catch (PricingException e) {
throw new RuntimeException(e);
} catch (RemoveFromCartException e) {
throw new RuntimeException(e);
}
request.setAttribute(mergeCartResponseKey, mergeCartResponse, WebRequest.SCOPE_GLOBAL_SESSION);
}
instead of :
Code: Select all
Customer anonymousCustomer = (Customer) request.getAttribute(CustomerStateRequestProcessor.ANONYMOUS_CUSTOMER_SESSION_ATTRIBUTE_NAME, WebRequest.SCOPE_GLOBAL_SESSION);
You should use :
Code: Select all
Customer anonymousCustomer = (Customer) request.getAttribute(CustomerStateRequestProcessor.getCustomerRequestAttributeName(), WebRequest.SCOPE_GLOBAL_SESSION);
because we have the possibility to override the method "getCustomerRequestAttributeName()".