Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Calvin Frei 106 posts 314 karma points
    Sep 22, 2016 @ 14:20
    Calvin Frei
    1

    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:

    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:

    base.CustomerContext.Reinitialize(customer);
    
    MerchelloContext.Current.Cache.RuntimeCache.ClearCacheByKeyExpression("merchello\\.itemcache.*\\." + customer.Key + "\\.");
    

    If I reload then the Checkout page the new address is there. Is this problem known?

    Thanks
    Calvin

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Sep 22, 2016 @ 14:56
    Rusty Swayne
    0

    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!!!

  • Calvin Frei 106 posts 314 karma points
    Sep 23, 2016 @ 06:40
    Calvin Frei
    0

    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!!

Please Sign in or register to post replies

Write your reply to:

Draft