Developer forum

Forum » Development » Setting PageView/Context from code

Setting PageView/Context from code

Søren Heide Larsen
Søren Heide Larsen
Reply

Hi,

We're currently trying to use MVC to add/change/remove items from a cart, but we are facing some issues.

The price becomes 0 as the DefaultPriceManager cannot find the current price. This is due to that the price is based on ShopId and the ShopId is null as the PageView is empty.

I am currenty considering using something like including pageId in the Controller Method and afterwards trying to set the PageView to ensure everything is calculated correctly, but what is the best practise for this?

And do anybody have some example code to override/set the PageView or Dynamicweb Context?

Best Regards
Søren


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Søren

Doing a Dynamicweb.Frontend.PageView.GetPageviewByPageID(123) should be enough... Sets the pageview context and Ecommerce context will pick that up.

BR Nicolai

Votes for this answer: 1
 
Søren Heide Larsen
Søren Heide Larsen
Reply

Great, thanks for the answer.

Had to set Dynamicweb.Ecommerce.Common.Context.Currency aswell as this was loaded with a wrong currency, but those combined worked like a charm.

/Søren

 

You must be logged in to post in the forum