How To Fix The Episerver Commerce SeoInformation Description MaxLength Issue

I was recently doing some product content migration for a recent project and part of the import data also included the products metadata/SEO properties for the web page like title, description and keywords tags. I started my import job and, about halfway through, it threw an exception that the MaxLength of the description property had been hit:( When you work with commerce entities like products, variant, catalogues you will have to have an object that inherits from EntryContentBase.  Within EntryContentBase is an object called SeoInformation, which I was using to store the products pages meta data.  As SeoInformation has a max limit and some of our product descriptions were auto-generated, my life became a lot more confusing.  I'm still a bit confused why there is such a small a cap on the description field so we had to come up with a workaround. Obviously, having two sets of meta-data properties for a content editor is confusing and pretty naff. In this instance, as I couldn't use SeoInformation, my only option was to hide SeoInformation from content editors and create a new set. In Episerver, we can use the [ScaffoldColumn] attribute to hide things from the content editors.  As SeoInformation can't be removed from EntryContentBase, it's the only option.  In your product and variant definitions override SeoInformation and apply the attribute.

        public override SeoInformation SeoInformation { get; set; }

Warning Do not use the [Ignore] attribute instead of as well as [ScaffoldColumn] because EPiServer will not let content editors publish pages, instead, they will get the following error: 'Property with name 'SeoInformation' is not part of the ContentType definition'. Now we have hidden SeoInformation, the next step was to define my own meta data properties:

        [Display(Name = "Meta Title",
                GroupName = "SEO",
                Order = 10)]
        public virtual string MetadataTitle { get; set; }

        [Display(Name = "Meta Description",
             GroupName = "SEO",
             Order = 20)]
        public virtual string MetadataDescription { get; set; }

        [Display(Name = "Meta Keywords",
             GroupName = "SEO",
             Order = 30)]
        public virtual string MetadataKeywords { get; set; }

On the product and variant layout, I then used these properties instead of the out of the box ones


Due to a silly character limit in commerce, you may not be able to use the out of the box SeoINfomration object defined within EntryContentBase.  To get around this limitation we hide SeoInformation from content editors using [ScaffoldColumn] and create our own version.

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + ''; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();