Copied to clipboard

Flag this post as spam?

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


  • Victor Bjørholm 58 posts 180 karma points
    Aug 26, 2020 @ 09:55
    Victor Bjørholm
    0

    Getting store guid

    Hi Matt, How do I go about programtically obtaining the store Guid? For the moment I have it hardcoded, but this brings in some problems whenever I deploy my site. I have tried looking at the StoreService, but I can't seem to get anything but a StoreReadOnly object out of it. Any ideas?

    /Victor

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 26, 2020 @ 10:01
    Matt Brailsford
    100

    Hi Victor,

    Your site root node should have a store picker on it with the alias of store. To get the store at any point in the site then, you can lookup that store property (which via a value converter returns a StoreReadOnly entity).

    var store = currentPage.Value<StoreReadOnly>("store", fallback: Fallback.ToAncestors);
    

    Or, if you are using models builder, you should be able to get it from your homepage node

    var store = currentPage.AncestorOrSelf<HomePage>().Store;
    

    From the store object, you can then get the ID from store.Id.

    /Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

    Continue discussion

Please Sign in or register to post replies