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
 

I am using 11.6 

#196612
Sep 05, 2018 16:11
 

Thanks Quan.

#196614
Sep 05, 2018 16:32
 

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
 

Thanks Quan !!

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

#198887
Edited, Nov 08, 2018 9:58
 

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
 

Hi Quan

I'm working with Epi Commerce 12+, and am running into a similar caching issue described above. Here's my scenario :

There is an approval process involved in our order processing system, where the cart should not be converted into a purchase order until its finally approved. But once a user had submitted one cart for approval, they should be able to create another cart, while the first is still pending. Now, i know Episerver does not allow multiple carts per user, but I read in another of your posts, where this can be achived by having a different cart name. So, i'm using that approach and when a cart is submitted for approval, I modify the cart name by appending some value to it. This works fine and saves correctly and I can see changes in commerce manager. However, the user still sees the last submitted cart as his active shopping cart, even though i have checks in place to look for cart name and other fields, when loading active cart. When i debugged this part, it seems like its loading from cache as same order group id that I just updated name on, shows as original name. If I clear browser cache or recycle app pool, I no longer see an active shopping cart and can create again.

Is there a way to remove just this specific cache object? Or can you recommend an alternate approach to deal with this?

Thanks!

#201910
Mar 06, 2019 19:47
Quan Mai
Member since: 2011
 

I'd suggest to create another thread. But as you already posted in this thread, here it goes

How does you load the cart? 

#201914
Mar 07, 2019 8:12
 

Hey Quan

I load cart by name, and then do additional checks on status, to see if i got the right cart. In this particular scenario, when I submit first cart, i change name to default name + id. Then once the page posts back, it tries to load active shopping cart, at which point I call Load cart by default name. This technically should return null, as i already updated name on existing cart, but since this stuff is cached and cache is not cleaned when cart name is changed, it loads the first cart, even though the name doesn't match.

#201935
Mar 07, 2019 15:59