Copied to clipboard

Flag this post as spam?

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


  • Christian Hansen 14 posts 85 karma points
    Apr 30, 2017 @ 12:14
    Christian Hansen
    0

    Merchello updating Entity Collections SortOrder in database and in need of refreshing cache

    Hey guys,

    Hope you can help me since i'm running out of options...

    I have a webshop that runs weekly food plans 1-4 weeks and it has to shuffle menus every week on sunday. Currently I made a service that does that automaticly, it works perfectly and changes the merchEntityCollection -> sortOrder correct with MSSQL in database - BUT it does not refresh my page with new menus untill I either push the webconfig or go into Umbraco and push save / publish.

    Is there a way in my service I can refresh Merchello cache so that the correct menu will be displayed on my page without doing anything manually?

    I've tried using umbraco.library.RefreshContent(); but that does not work since the nodes inside Merchello are different.

    Best regards, Christian

  • Christian Hansen 14 posts 85 karma points
    May 03, 2017 @ 20:51
    Christian Hansen
    0

    Bump...Can no one really help me? Do I need to specify my question more?

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 04, 2017 @ 14:01
    Rusty Swayne
    0

    Hi Christian - I'm out of town, so sorry for the late reply.

    My guess is you just need to clear the cache after your operation.

    The cache key for Merchello entities is generated here:

    https://github.com/rustyswayne/Merchello/blob/merchello-dev/src/Merchello.Core/Cache/CacheKeys.cs#L172

    So maybe something as simple as:

    ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(typeof(IEntityCollection).Name);

    ?

  • Christian Hansen 14 posts 85 karma points
    May 04, 2017 @ 14:18
    Christian Hansen
    0

    Hi Rusty,

    No problem - I just saw activity in the other posts here. But thank you so much for your suggestion - I will try it out ASAP and report back.

    Have a great day!

    Best regards, Christian

  • Christian Hansen 14 posts 85 karma points
    May 04, 2017 @ 19:17
    Christian Hansen
    0

    I couldnt find a way to get my Entity CacheKey to use with ClearCacheByKeySearch(), but I managed to get it to work with ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache() Think it will be okay to use that once a week or is it overkill? I would prefer to use your solution though...but it works now.

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 04, 2017 @ 22:34
    Rusty Swayne
    0

    Hmm - must have the prefix slightly incorrect. Can you post your update code? Dumping everything from cache seems pretty heavy handed :-)

  • Christian Hansen 14 posts 85 karma points
    May 05, 2017 @ 07:29
    Christian Hansen
    0

    Heavy handed indeed :-) My update code is pretty straight forward, I am using ajax to send a request if sort order rotation is being done and if its done it returns result and I then just execute this code:

    ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache() I am using FastTrack and this code is being executed within FastTrack.cshtml

    When I use: ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(typeof(IEntityCollection).Name)

    Then IEntityCollection tells me: The type or namespace name 'IEntityCollection' could not be found (are you missing a using directive or an assemly reference?)

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 09, 2017 @ 03:54
    Rusty Swayne
    0

    IEntityCollection is in the Merchello.Core.Models.Interfaces namespace ... which is actually an error. It should be in the Merchello.Core.Models namespace.

    Does it work if you add a using Merchello.Core.Models.Inferfaces statement?

    Issue added to correct the namespacing: http://issues.merchello.com/youtrack/issue/M-1319

  • Christian Hansen 14 posts 85 karma points
    May 30, 2017 @ 19:00
    Christian Hansen
    1

    Sorry for replying so late, been busy and didn't get around to trying out your suggestion - but I finally got back to it and it works wonders when adding the Merchello.Core.Models.Interfaces namespace.

    Thank you so much for your time and help Rusty Swayne, really appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft