Wednesday, October 8, 2014

How to hide SeoInformation in EPiServer Commerce

When working with EPiServer Commerce you will see that all products, variants and categories automatically will receive a block in the Information tab called "SeoInformation". In several of our projects we don't want to display this block, we'd rather create our own SEO properties.

The SeoInformation block comes from the ISearchEngineInformation interface that all the following classes implement: NodeContent, BundleContent, PackageContent, ProductContent and VarianContent. So if you don't want the SeoInformation property to be displayed on any of your products, variants and categories, you will need to override the property on all your classes inheriting from ProductContent, VariationContent and NodeContent. 
For example: 
public abstract class BaseProductData : ProductContent
{
    [ScaffoldColumn(false)]
    public override SeoInformation SeoInformation { get; set; }
}

Now, you might be tempted to add an Ignore attribute to the property as well, but if you do that EPiServer will give the the following error when trying to publish: "Property with name 'SeoInformation' is not part of the ContentType definition"


Which of course, is logical as EPiServer won't find the SeoInformation property on the ContentType model. So if you find yourself receiving this error message, make sure you're not using the Ignore attribute on the property in question.


No comments:

Post a Comment