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 41 posts 121 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 2807 posts 14331 karma points MVP 7x 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

Please Sign in or register to post replies

Write your reply to:

Draft