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.

  • Logan P. 47 posts 217 karma points
    May 16, 2014 @ 18:12
    Logan P.
    0

    Populate SiteContext manually?

    Hello all,

    Please forgive me if this is a simple question. I am building an example store from scratch to help verify the business requirements for our next Umbraco site. I am using route hijacking so I can have my own controllers and do my own routing (i.e. not using the uCommerce url rewriting). My url's then look like "/Store/Catalog/Category/product?catalogName=SpringCatalog&productId=200".

    I am having a problem with everything in SiteContext being null, which I sort of would expect since I am not using the url rewriting rules for uCommerce. My question is: Is there a way that I can build my SiteContext in my controller or route every request through the pipeline that populates the SiteContext?

    I have been able to get around the SiteContext being null problem until I try to have a CartAPIController which extends the UmbracoApiController. I want to be able to add a product to a cart by calling

    SiteContext.Current.OrderContext.GetBasket().PurchaseOrder.AddProduct(priceGroup, product, quantity);
    

    Thanks!

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 21, 2014 @ 10:05
    Søren Spelling Lund
    0

    Hi Logan,

    If you change your parameters to catalog, category, and product SiteContext will automatically populate.

    Alternatively you can set up the context yourself based on whatever info you have available in your routes like so:

    SiteContext.Current.CatalogContext.CurrentCategory = someCategory;

    This can be done for all aspects of the CatalogContext.

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft