Upgrading to #Episerver Commerce 11 – a developer’s memorandum

The upgrade went …. smooth! This is my notes.

Published 11th of August 2017
Episerver Commerce Version 10.8 to 11.0

What’s new in Episerver Commerce 11?

Commerce 11 includes improved home category handling for entries, improved API for relations and associations, catalog import handling of cleared fields consistent with the API, implementation of the IShippingGateway and IShippingPlugin, and the removal of old Asset Management system. – Episerver World

Merchandisers, read this: http://world.episerver.com/blogs/David-Bowen/Dates/2017/7/commerce-11-release/

Episerver Commerce 11 is a new major version containing some incompatible API changes. Depending how good you have worked with all obsolete messages in your solutions, you probably won’t even have these errors… but because of time and priorities this may not been done. This is my notes from the upgrade done on a multi site commerce solution with legacy code from version 5.1. It might help someone.

Before upgrading read the official commerce blog posts on this topic http://world.episerver.com/product-blogs/the-commerce-blog/

Incompatible changes/removed methods:

Helper methods of static EPiServer.Business.Commerce.StringExtension – Methods has been moved to the namespace ‘EPiServer.Commerce.Extensions’

ShipmentTotal on Shipment – Use ShippingSubTotal instead since it more accurately describes the actual value.

Lineitem.CatalogEntryId – This property has been renamed to ‘Code’, because it better describes the value.

Mediachase.Commerce.Security.SecurityContext.AssignUserToGlobalRole – If using Membership use Roles.AddUserToRole(user.UserName, globalRoleName) instead. Otherwise use configured security api.

Mediachase.Commerce.Security.SecurityContext.GetAllRegisteredRoles – Use ServiceLocator.Current.GetInstance<SecurityEntityProvider>().SearchRoles(“partofname”) instead.

Mediachase.Commerce.Security.SecurityContext.CurrentUser – The system does not consider this property. Instead it uses the property EPiServer.Security.PrincipalInfo.CurrentPrincipal. You can set the value to specific user name by using EPiServer.Security.PrincipalInfo.CurrentPrincipal = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(username), null). Note CustomerContext.Current.CurrentContact may be used Membership.GetUser(CustomerContext.Current.CurrentContact.UserId);

CustomerContext.GetAllOrganization – This method has been obsoleted because of bad naming. Use ‘GetOrganizations’ instead.

Mediachase.Commerce.Core.AppContext.Current.ApplicationId is not used anymore.

Mediachase.Commerce.Engine.Navigation.UrlService – This class should no longer be used. Use UrlResolver instead.

Mediachase.Commerce.Website.Handlers.StaticCatalogUriHandler – This class is no longer needed. If you have upgraded from 5.1, you may have this left in you web.config, so remove <add name=”EcfCatalogHandler” verb=”*” path=”*.aspx” preCondition=”integratedMode” type=”Mediachase.Commerce.Website.Handlers.StaticCatalogUriHandler, Mediachase.Commerce.Website” /> from web.config. It is a leftover from the time when you hade a static aspx width querystring parameter “ec” (entry code) and “nc” (node code)

Episerver Commerce 11 requires .NET target framework to be 4.5.2 or higher. https://world.episerver.com/documentation/upgrading/episerver-commerce/commerce-11/target-framework/


If you still work with workflows/activity-flows, download and check for updates https://world.episerver.com/download2/, Lineitem.WarehouseCode is obsolete in version 10, but anyhow not removed in 11, therefore may your flows and code still work, but the recommendation is not to use the Lineitem.WarehouseCode approach.

More reading:

SEO terms:

  • Tutorial upgrade Commerce 11
  • Episerver Commerce 11 update

Convert Deprecated Gadgets to Components in #Episerver

This guide shows you how you easily can convert your obsolete MVC gadgets to Component without being a dojo guru. With or without MVC pattern.

Published 8th of June 2017
For Episerver Version 10.6

Gadgets is obsolete from CMS version 10.6

Gadgets has been around in Episerver since CMS 6, and the foremost advantage with Gadget pattern compared with the recommended Components was that it was easy to implement (just make a controller and decorate it with some attributes), quite straight forward and easy. The Components framework seems a little bit more complex, the examples provided by Episerver are involving dojo javascript programming which may not be intuitive to so many, yeah, maybe to no one 😉

BUT Episerver provides a short cut, IFrameComponent, with which I will use to illustrate how you easily can upgrade your gadget to component.

You might think IFrame suck, but if you don’t need the Episerver context, for example in dashboard, this might be a good way. I’m planning to write a guide how do upgrade this example without IFrame, and with dojo, but we’ll see about that.

This example is for administrating users for the also obsolete and legacy Subscription system build in Episerver. It is a dashboard for listing and removing users from the subscriptions on the website.

So let’s start with legacy gadget:

Change Gadget to IFrameComponent, add URL property, and categories, remove all resources. Categories can be “cms,content,dashboard”

The URL must relate to the routing added

In this example I´m not using any view instead just returning HTML from a string. But view will work as usual. You’ll just need to add a _layouts with your resources. In my code I just inline it in the htmlstring.


Gist: https://gist.github.com/LucGosso/ec1c38d9bb7a2360fc276a693ef8dd6c CS and JS file


SEO terms:

  • The Episerver gadget framework has been deprecated and was replaced by the Episerver Components.
  • How to convert EPiServer gadget to component
  • Creating a component without dojo
  • Gadget to Component with MVC views
  • Create an IFrame Component from a Dashboard gadget
  • Component to administrate subscription users in Episerver

Extending #Episerver.forms with URL QueryString/post Value Element

How to extend Episerver Forms with a hidden QueryString/HttpPost Value Element.

Published 22nd of May 2017
For Episerver Version 10 and Forms > 4.4

Security warning! Be aware of how you use url parameters. This may be a security risk. Use at own risk or not at all.

Had a case where I needed to save a PageId into a form, similar to an order functionality.

You need an Element model:

And the view (which is a copy of built in PredefinedHiddenElementBlock.ascx)

Save your view under views/shared/elementblocks/

When using the element, just fill in the “Predefined value” with the key used by Querystring or form post.

It pops up in the form elements pane:

And in onpage edit:

In email placeholder you’ll find #OrderId#:

Use it wizely with httpGet or HttpPost

More reading

SEO terms:

  • Hidden post value in element of Episerver Form
  • How to extend episerver forms with querystring value

Get page property from submitting page in #Episerver.Forms

How to read a querystring value from the referrer/hosted form page. Also how to read a page property from the submitting page.

Published 16th May 2017
For Episerver Version 10 and Forms > 4.4

By implementing IPlaceHolderProvider in the Episerver.Form.UI  Namespace > 4.4 you can use it to add your own implementation of the Placeholder tags in email, eg #yourelement#

You’ll need to add an ExtraPlaceHolder called eg #SomePageProperty# and then implement it under ProcessPlaceHolders.

Important to remember! All placeholders in ProcessPlaceHolders will be triggered on every submit, even if it is not used in that form.

In the submissionData object, you have a SYSTEMCOLUMN_HostedPage item, where the id of the page submitting is saved, this is what we’ll use.

In some scenarios you may want to read the referrer page querystring, this may be used with HttpUtility.ParseQueryString(requestBase.UrlReferrer.Query)[“key”]

!Security warning! Be aware of how you use url parameters. This may be a security risk. Use wisely or not at all.

In my next upcoming blog post I will show how you can save http posted values into hidden formelements, but also querystring values.

Gist: https://gist.github.com/LucGosso/08ebb442e42cbb7fe239afe63ea95df5

More reading:

SEO terms

  • Extending Episerver forms
  • Customize email