Created
May 18, 2016 12:40
-
-
Save casper-rasmussen/36964bf818b7fd89b483996501858cfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [InitializableModule] | |
| [ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))] | |
| public class CommerceRoutingInitialization : IInitializableModule | |
| { | |
| public void Initialize(InitializationEngine context) | |
| { | |
| ReferenceConverter converter = context.Locate.Advanced.GetInstance<ReferenceConverter>(); | |
| ContentReference rootReference = converter.GetRootLink(); | |
| IContentRepository contentRepository = context.Locate.Advanced.GetInstance<IContentRepository>(); | |
| CatalogContentBase commerceRoot = contentRepository.Get<CatalogContentBase>(rootReference); | |
| var customRouter = new TabHierachicalCatalogRouter(commerceRoot, (Func<ContentReference>) (() => | |
| { | |
| if (!ContentReference.IsNullOrEmpty(SiteDefinition.Current.StartPage)) | |
| return SiteDefinition.Current.StartPage; | |
| return SiteDefinition.Current.RootPage; | |
| })); | |
| RouteTable.Routes.RegisterPartialRouter(customRouter); | |
| } | |
| public void Preload(string[] parameters) { } | |
| public void Uninitialize(InitializationEngine context) | |
| { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment