Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide
GitHubNuGetDev CommunityOptimizely AcademySubmit a ticket

Optimizely developer documentation

How can we help you?

Try our conversational search powered by Generative AI!

AI OnAI Off

Assets and media

Describes asset and media management in Optimizely Commerce Connect 13.

The asset management system supports generic, content-based files, used by Optimizely products such as Content Management System (CMS) and Commerce (PaaS). Assets, such as blocks and media files in CMS, are accessible in the Assets pane of the Edit user interface and the product catalog in Commerce (PaaS). Media files are images, videos, and documents.

See the Content section of the CMS Developer Guide for information about the Optimizely platform content model and asset management. This topic describes the Commerce (PaaS)-specific parts of the assets management integration.

📘

Note

Entry-associated assets, which correspond to the For this page folder in CMS, are not available for Commerce (PaaS). You can only work with shared assets for commerce content.

Asset management in Commerce (PaaS)

The content-based asset management system with the BLOB provider model adds assets to the catalog nodes and entries when you manage catalogs. Files are stored in the same location as the CMS files, providing a unified user experience.

In a Commerce (PaaS) installation, you can access products and product variants from the product catalog via the Catalogs gadget in the Assets pane, with support for drag and drop of content items into CMS pages and blocks. The integration is done using content type classes EPiServer.Commerce.Catalog, EPiServer.Commerce.Catalog.ContentTypes and EPiServer.Commerce.Catalog.Provider.

Default asset for content

EntryContentBase and NodeContent implements IAssetContainer, which contains the property CommerceMediaCollection. Content that implements IAssetContainer can contain several assets. In many cases, only one of the assets is shown at the site. The first item in the asset collection list is used in the UI by default. See also Asset URL resolver.

using EPiServer.Commerce.Catalog.ContentTypes; using EPiServer.Commerce.SpecializedProperties; using EPiServer.Core; using EPiServer.DataAbstraction; using EPiServer.DataAccess; using EPiServer.Security; using EPiServer.Web; using System.ComponentModel; using System.Globalization; namespace EPiServer.Commerce.Catalog { public class AddAssetSample { private AssetUrlResolver assetUrlResolver; private ReferenceConverter referenceConverter; private IContentLoader contentLoader; private AssetUrlConventions assetUrlConventions; private IContentRepository contentRepository; private ContentMediaResolver mediaDataResolver; private ContentTypeRepository contentTypeRepository; public void AddAssetToVariation() { ContentReference rootCatalogLink; //Get a suitable MediaData type from extension var mediaType = mediaDataResolver.GetFirstMatching("jpg"); var contentType = contentTypeRepository.Load(mediaType); //Get a new empty file data var media = contentRepository.GetDefault<IContentMedia>(SiteDefinition.Current.GlobalAssetsRoot, contentType.ID); media.Name = "MyImages"; var contentLink = contentRepository.Save(media, SaveAction.Publish, AccessLevel.NoAccess); // Add asset to variation var variation = contentRepository.GetDefault<VariationContent>(rootCatalogLink, CultureInfo.GetCultureInfo("en-US")); variation.Name = "Variation name"; contentRepository.Save(variation, SaveAction.Save, AccessLevel.NoAccess); var commerceMedia = new CommerceMedia() { AssetLink = contentLink }; variation.CommerceMediaCollection.Add(commerceMedia); } } }

Did this page help you?