Load Order Without Cache

 

Hello,

We have a process that changes the order data via a stored procedure. The issue we are running into is that when we then load up the order via the order repository, the order is pulling from a cached version that does not have the changes the store procecure executed. Through my research, I havent found a way yet to load up the order fresh and not from cache. Is there a way to do this?

Thank you.

#191365 Apr 24, 2018 21:34
  • Quan Mai
    Member since: 2011
     

    We advise against such direct data manupulation. Is there any reason you can't use the APIs to update the order?

    Technically you can remove the cache before loading the order, but that would be expensive.

    #191421 Edited, Apr 24, 2018 21:57
  •  

    There is a complicated process that integrates with a 3rd party outside epi that we cant change. We usually try to avoid direct manipulation, but was not an option in this case.

    I am assuming removing the cache would effect everything and not just the one order?

    #191433 Apr 24, 2018 22:03
  • Quan Mai
    Member since: 2011
     

    Basically yes. We don't disclose how is the cache key is constructed (it's internal implementation), and there might be more than 1. So to be "safe" you would need to clear the cache, and that'd be expensive.

    Is it possible to share which data are you updating? I don't think that can't be done via APIs which adequate performance. 

    #191448 Apr 24, 2018 22:12
  •  

    We are updating data on order group and purchase order. We have a workaround in place now that seems to work without having to clear cache.

    Thanks for your help.

    #191458 Apr 24, 2018 22:18
  •  

    Hallo ,

    I have the same problem . I am saving my cart from orderrepository but it is reflected after Irestart my solution.

    I can't fetch the updated repository.

    _wishlist.Name = "wishList";
    DateTime today = DateTime.Today;
    Cart.Properties["DeliveryDate"] = today;
    Cart.Properties["DeliveryTime"] = DateTime.Now.ToString("HH:mm");
    var result = _orderRepository.Save(Cart);

    //saves my current cart as wishlist

     var wishlistsOrders = _orderRepository.Load(_customerContext.CurrentContactId, string.Empty)

    //loads my wishlists but doesn't lods the one just updated above.

    //loads it after I have restarted the solution.

    Any input will be great help.

    #196602 Sep 05, 2018 15:31
  • Quan Mai
    Member since: 2011
     

    Himshikhar Verma How do you load your Cart at the first place? 

    #196604 Edited, Sep 05, 2018 15:34
  •  

    private ICart Cart
    {
    get { return _wishlist ?? (_wishlist = _cartService.LoadCart(_cartService.DefaultCartName)); }
    }

    //this loads my current cart.

    #196605 Sep 05, 2018 15:43
  • Quan Mai
    Member since: 2011
     

    Hmm, I think there is a bug in our side, I'll file a bug for it.

    In the meanwhile, what you can do is to load the wishlist by  

     _orderRepository.Load(_customerContext.CurrentContactId, _cartService.DefaultCartName);

    instead.

    I'm not sure why you are using "DefaultCartName" for wishlist, but that's your decision 

    #196607 Sep 05, 2018 15:51
  • Quan Mai
    Member since: 2011
     

    Actually we already had the bug COM-6485, which was fixed and released in Commerce 11.8.2

    Your best option should be upgrade to latest version (well, you can upgrade to that exact version, but newer version is better) 

    #196608 Sep 05, 2018 15:55
  •  

    Actually..we are using "Default" as cart and we are saving a cart as our wishlist by updating the name of our cart.

    if (Cart == null)
    {
    _wishlist = _cartService.LoadOrCreateCart(_cartService.DefaultCartName);
    }
    _wishlist.Name = "wishList"; // cart name updated here
    DateTime today = DateTime.Today;
    Cart.Properties["DeliveryDate"] = today;
    Cart.Properties["DeliveryTime"] = DateTime.Now.ToString("HH:mm");
    var result = _orderRepository.Save(Cart);

    In this way we moved cart with name "Default" to wishlist named as "Wishlist" in the orderrepository.

    But when I tried to load the all saved wishlist I can fetch it using..

    var wishlistsOrders = _orderRepository.Load(_customerContext.CurrentContactId, string.Empty);

    But above code does not returns me the cart we saved as "wishlist".

    it return all the objects in "wishlistsOrders " as cart.name="Default".

    In this way we are not able to display the updated wishlist at current time becoz we can anly display cart with name as "wishlist".

    #196610 Edited, Sep 05, 2018 16:02
  •  

    Actually we already had the bug COM-6485, which was fixed and released in Commerce 11.8.2

    Your best option should be upgrade to latest version (well, you can upgrade to that exact version, but newer version is better) 

    I am using 11.6 

    #196612 Sep 05, 2018 16:11
  •  

    Thanks Quan.

    #196614 Sep 05, 2018 16:32
  •  

    Actually we already had the bug COM-6485, which was fixed and released in Commerce 11.8.2

    Your best option should be upgrade to latest version (well, you can upgrade to that exact version, but newer version is better) 

    How can I avoid the cache as when I save my cart or delete it in repository.

    Is there any workaround which I can use to avoid loading my updated repository from cache?.

    It will be a great input.

    Thanks!

    #196655 Sep 06, 2018 10:28
  • Quan Mai
    Member since: 2011
     

    Upgrading to 11.8.2 should be much easier solution than having to work around the cache system (which is, pretty internal, and should not be touched ) 

    #196656 Sep 06, 2018 10:35
  •  

    hello ,

    When I tried updating Eoiserver commerce , I had below exception.

    While loading .NET types from "EPiServer.Commerce.UI.CustomerService" the following error(s) was reported (limited to first 10 errors):

        - System.IO.FileLoadException: Could not load file or assembly 'EPiServer.Shell, Version=11.7.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    File name: 'EPiServer.Shell, Version=11.7.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'

    === Pre-bind state information ===
    LOG: DisplayName = EPiServer.Shell, Version=11.7.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
    (Fully-specified)
    LOG: Appbase = file:///C:/Users/Himshikhar/source/repos/protan.shop/Sources/EPiServer.Reference.Commerce.Site/
    LOG: Initial PrivatePath = C:\Users\Himshikhar\source\repos\protan.shop\Sources\EPiServer.Reference.Commerce.Site\bin
    Calling assembly : EPiServer.Commerce.UI.CustomerService, Version=12.11.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7.

    Solved many dependencies exceptions but didn't found a way to resolve this.

    #198840 Nov 07, 2018 15:06
  • Quan Mai
    Member since: 2011
     

    This should be in new thread instead. Which is the version of EPiServer.Shell in bin folder?

    #198842 Nov 07, 2018 15:16
  •  

    11.2

    #198843 Nov 07, 2018 15:24
  • Quan Mai
    Member since: 2011
     

    Isn't that self-explanatory? EPiServer.Commerce.UI.CustomerService, Version=12.11.0.0 requires at least EPiServer.Shell 11.7. When you upgrade Commerce it should also update other dependencies.

    #198845 Nov 07, 2018 15:26
  •  

    yes, but the thing is we didnt updated any of the dlls to 12.11 and there are many other dlls who want to execute episerver.shell 11.2

    #198847 Nov 07, 2018 15:28
  • Quan Mai
    Member since: 2011
     

    Then why do you have  EPiServer.Commerce.UI.CustomerService, Version=12.11.0.0 in your bin folder?

    #198849 Nov 07, 2018 15:29
  •  

    Not sure though , how i have 12.11 as  EPiServer.Commerce.UI.CustomerService in my bin.

    #198852 Nov 07, 2018 15:37
  •  

    That is something I am trying to figure out.

    #198853 Nov 07, 2018 15:38
  • Quan Mai
    Member since: 2011
     

    Check all references and make sure the dll is deleted from bin? 

    #198854 Nov 07, 2018 15:40
  •  

    Check all references and make sure the dll is deleted from bin? 

    Thanks Quan !!

    I deleted bin folder and updated the database and it worked.

    #198887 Edited, Nov 08, 2018 9:58
  •  

    Actually we already had the bug COM-6485, which was fixed and released in Commerce 11.8.2

    Your best option should be upgrade to latest version (well, you can upgrade to that exact version, but newer version is better) 

    Hello ,

    We successfuly updated the version to 11.8.2 but the problem still persists.

    #198908 Nov 08, 2018 12:20
  • Quan Mai
    Member since: 2011
     

    that's odd. I would suggest to contact developer support for further assistance. Based on the information you provided, then the bug fix in that version should have fixed it (you should probably upgrade to 11.8.5 which is the last version of 11.x anyway), so there might be something that was not mentioned/discovered 

    #198910 Nov 08, 2018 12:45