Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Terry Clancy 204 posts 944 karma points
    May 15, 2015 @ 09:00
    Terry Clancy
    0

    How to change the uCommerce "Current" Store , Catalog and/or Category

    Hi again,

    I am writing code base on the Razor Demo Store.  I have the demo store running in Umbraco and I have previously written code to create a adjacent Store with it's own   Stores , Catalogs ,  Categories &  Products.

    Now I m creating a Catalog page I have the following code:

    @RenderNavigation(CatalogLibrary.GetRootCategories(), SiteContext.Current.CatalogContext.CurrentCategory)

    But is results in the display of the Catalogs ,  Categories &  Products in the DEMO Store, not my new store and it's contents.

    How do I change the "Current"   Store , Catalog  and/or Category so that this code shows information from my new store please.

    Thanks

    Terry Clancy

    ClanceZ

  • Martin 181 posts 740 karma points
    May 15, 2015 @ 13:27
    Martin
    0

    Hi Terry,

    uCommerce looks up by default for hostname bindings on your Store, if none is present then uCommerce will select the first store in your solution. So what you can do

    • Setup a hostname binding on your new store
    • Create a custom implementation of CatalogContext where you define which logic should be used for selecting your store.

    best regards Martin

  • Terry Clancy 204 posts 944 karma points
    May 21, 2015 @ 21:24
    Terry Clancy
    100

    Thanks very much Martin,

    Based on your suggestion I created the following code which solves the issue. I still have the same store as the first store but the Menu now populates from my new (second) store nased on that store's Catalog name:

     

    @{ Category myCategory = newCategory();

    ProductCatalog myProductCatalog = ProductCatalog.Find(x => x.Name == "MyCatalogName").First();

    SiteContext.Current.CatalogContext.CurrentCatalog = myProductCatalog;

    ICollection<Category> rootCategories = CatalogLibrary.GetRootCategories();

    Category myCurrentCategory = rootCategories.First();

    }

    @RenderNavigation(rootCategories, myCurrentCategory);

     

    Thanks again

    Terry Clancy

    ClanceZ

     

     

     

     

     

     

     

     

     

     

     

     

       

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft