There we have a Profile site for the customer to edit his addresses (so not only in the Checkout).
The addresses are posted with a SurfaceController and updated/created through:
customer.SaveCustomerAddress(address);
The problem is, that when I go to the Checkout the new address is not there.
So I've added:
base.CustomerContext.Reinitialize(customer);
but then somethimes I get an error in the Checkout because the
basket.Customer.Addresses
has a null value (if I do CustomerService.GetByKey(key).Addresses the new address is there, but not in the basket.GetCheckoutManager().Context.Customer.Addresses). I cannot tell why. Sometimes it works, sometimes not, so maybe a caching issue?
Tried also to refresh the basket through
customer.Basket().Refresh();
but then still the old customer (not with the new address) is taken to create the new Basket(...); (I've debugged it with the pdb files).
The only thing which seems to work yet is this "hack" after saving the address:
The problem is that the customer is being cached by both the service and then again as a second cache item in the CustomerContext. This was obviously an oversight.
Profile to edit the Addresses
Hi Rusty
I have an existing Shop with Merchello 2.1.0.
There we have a Profile site for the customer to edit his addresses (so not only in the Checkout). The addresses are posted with a SurfaceController and updated/created through:
The problem is, that when I go to the Checkout the new address is not there.
So I've added:
but then somethimes I get an error in the Checkout because the
has a null value (if I do CustomerService.GetByKey(key).Addresses the new address is there, but not in the basket.GetCheckoutManager().Context.Customer.Addresses). I cannot tell why. Sometimes it works, sometimes not, so maybe a caching issue?
Tried also to refresh the basket through
but then still the old customer (not with the new address) is taken to create the new Basket(...); (I've debugged it with the pdb files).
The only thing which seems to work yet is this "hack" after saving the address:
If I reload then the Checkout page the new address is there. Is this problem known?
Thanks
Calvin
Interesting that you ran into this as I just logged it as a "probable" issue http://issues.merchello.com/youtrack/issue/M-1132 that will be refactored out in Merchello V3.
The problem is that the customer is being cached by both the service and then again as a second cache item in the CustomerContext. This was obviously an oversight.
Last week I added a check for the null which II ran into when setting up some test I was running https://github.com/rustyswayne/Merchello/blob/merchello-dev/src/Merchello.Core/Models/CustomerExtensions.cs#L361 - this will be in the 2.3.0 release.
Unfortunately I'm stuck with a sort of "mitigation" rather than a fix for the moment, but it is on the radar and will be refactored out in V3.
Nice catch - and thanks for the write up!!!
Ahhh... so it's a sort of caching issue.
It seems to work with the hack above so I'll look at it again when Merchello v3 is out :-P.
Thanks!!
is working on a reply...