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?
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.
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
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 aStoreReadOnly
entity).Or, if you are using models builder, you should be able to get it from your homepage node
From the store object, you can then get the ID from
store.Id
./Matt
is working on a reply...