HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


## Access catalog content as IContent

Optimizely Customized Commerce provides a content provider that can serve any catalog content as IContent. That means that you can use an IContentRepository to work with the content as you do in Optimizely Content Management System (CMS).

Sample code



For information about displaying Customized Commerce content, see [Commerce rendering templates](🔗).

## Content model

To get the full feature set, you need to connect a content type to the meta-class. Do that by creating a model class that inherits from the appropriate type in the EPiServer.Commerce.Catalog.ContentTypes namespace and decorating it with the CatalogContentTypeAttribute attribute.

Sample code



The following types are available when you create Customized Commerce models.

Type nameDescription
VariationContentA type for variant/SKU models.
ProductContentA type for product models.
BundleContentA type for bundle models.
PackageContentA type for package models.
NodeContentA type for category/node models.

You should not inherit from the following types because they exist only to show various states in the system:

Type nameDescription
CatalogContentA type for catalog models.
EntryContentBaseA base type for VariationContent, ProductContent, BundleContent, PackageContent and DynamicPackageContent.
NodeContentBaseA base type for NodeContent and CatalogContent.
RootContentThe virtual root in Optimizely's hierarchical representation of Commerce content.

During the synchronization process, specific CLR types generate meta-fields of a specific MetaDataPlus type. You can modify the default mapping by using the BackingTypeAttribute. The following table shows mappings for all supported types.

**Mappings for all supported types**

CLR TypeMetaDataPlus Type
ByteInteger (SmallInt, TinyInt and Int are also supported)
Int16Integer (SmallInt, TinyInt and Int are also supported)
Int32Integer (SmallInt, TinyInt and Int are also supported)
Int64Integer (SmallInt, TinyInt and Int are also supported)
DoubleFloat
SingleFloat
FloatFloat
DecimalDecimal
StringLongString (ShortString and Text are also supported)
BooleanBoolean
DateTimeDateTime (Date and SmallDateTime are also supported)
UrlUrl
XhtmlStringLongHtmlString
ContentReferenceShortString
PageReferenceShortString

## Commerce-specific attributes

Any attribute you can use in CMS can also be used in Customized Commerce content type models. You can decorate your model with the following Commerce-specific attributes:

  • CatalogContentTypeAttribute To connect the content type to an existing meta-class, use the CatalogContentTypeAttribute. Connect them by defining the name of the meta-class that should be connected to the content type.

Sample code


  • EncryptedAttribute. Use to declare a property to enable Use Encryption. This encrypts the value when stored in MetaDataPlus.

  • UseInComparisonAttribute. Use attribute to declare a property to be used for comparison.

  • IncludeInDefaultSearchAttribute. Use to declare a property to include the value in default search results. This will be used by the search provider system.

  • IncludeValuesInSearchResultsAttribute. Use to declare a property to be included in search results. This will be used by the search provider system.

  • SortableInSearchResultsAttribute. Use to declare a property to be flagged as index sortable. This will be used by the search provider system.

  • TokenizeAttribute. Use to declare a property to be tokenized (word breaking).

  • DecimalSettingsAttribute. Use to declare a property to have precision and scale.

## Commerce-specific types

The types you can represent in MetaDataPlus are not directly mapped to a CLR type. Properties that are backed by meta-fields of these MetaDataPlus types need to be specified beyond return type. The following table lists such MetaDataPlus types and additional requirements.

Note

The use of Commerce-specific types is not supported within blocks.

MetaDataPlus TypeCLR TypeAdditional Requirements
DictionarystringDecorated with [BackingType(typeof(PropertyDictionarySingle))]
Dictionary, multilineItemCollection<string>Decorated with [BackingType(typeof(PropertyDictionaryMultiple))]
**StringDictionary type is new in Commerce 13.1**

StringDictionaryIDictionary\<string,string>Decorated with [BackingType(typeof(PropertyStringDictionary))]

Note

To define a property that maps to a StringDictionary metafield, use this example: [BackingType(typeof(PropertyStringDictionary))] public virtual IDictionary\<string, string> StringDict { get; set; }

To change the values of that StringDictionary metafield, update the property as a normal dictionary. Example: content.StringDict = new Dictionary\<string, string>() {{ "abc", "xyz" }, {"hello", "world"}};

See also [New feature in Commerce 13.1: StringDictionary support for catalog content](🔗)

## Limitations in synchronization

The synchronization of catalog models works the same way as with content types in CMS, except the data is backed in MetaDataPlus. However, there are some limitations due to technical differences. The following are not done automatically. They require manual steps:

  • Change a property type. Causes an exception.

  • Rename a model class. Unless specified by the CatalogContentTypeAttribute, a new meta-class is added, but the old one is left in the system.

  • Rename a property. Adds a new meta field, but the old one is left in the system.

  • Remove a property.

Different properties with the same name must have identical definitions. For example, you cannot have a property called _Description_ on two different classes and make it culture-specific on one, but not the other. This is because, in MetaDataPlus, meta fields are shared across meta classes. Hence, they can only have one definition. See [Synchronization](🔗).

## List properties

Beginning with CMS 11, Customized Commerce has a PropertyValueList that lets editors input multiple primitive values. Available types are:

  • Int

  • String

  • Double

  • DateTime

You can add a list as a new property in your model.

Sample code



Sample results

556