Skip to content

Instantly share code, notes, and snippets.

@casper-rasmussen
Created May 22, 2016 14:10
Show Gist options
  • Save casper-rasmussen/598f6a099ece9f564110d1e5c8ee20af to your computer and use it in GitHub Desktop.
Save casper-rasmussen/598f6a099ece9f564110d1e5c8ee20af to your computer and use it in GitHub Desktop.
class BaseProductContentBuilder : EntryBuilder
{
/// <summary>
/// Initializes a new instance of the <see cref="T:EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder"/> class.
///
/// </summary>
/// <param name="catalogContext">The catalog context.</param><param name="metaClassContentFactory">The meta class content factory.</param><param name="catalogPropertyLoader">The catalog property loader.</param><param name="referenceConverter">The reference converter.</param><param name="contentVersionDB">The catalog content Database access.</param>
[DefaultConstructor]
public BaseProductContentBuilder(ICatalogSystem catalogContext, MetaClassContentFactory metaClassContentFactory, ICatalogPropertyLoader catalogPropertyLoader, ReferenceConverter referenceConverter, CatalogContentVersionDB contentVersionDB)
: base(catalogContext, metaClassContentFactory, catalogPropertyLoader, referenceConverter, contentVersionDB)
{
}
public override bool HandleType(CatalogContentType catalogContentType)
{
return catalogContentType == CatalogContentType.CatalogEntry;
}
public override IList<CatalogContentBase> CreateVersions(IList<ContentReference> contentLinks)
{
IList<CatalogContentBase> internalVersions = base.CreateVersions(contentLinks);
foreach (CatalogContentBase internalVersion in internalVersions)
{
if (internalVersion.Language.Equals(internalVersion.MasterLanguage))
continue;
int objectId = this.ReferenceConverter.GetObjectId(internalVersion.ContentLink);
Entry entry = this.CatalogContext.GetCatalogEntry(objectId);
MetaObjectAccessor accessor = new MetaObjectAccessor(objectId, entry.MetaClassId);
if(internalVersion.Status.Equals(VersionStatus.CheckedOut) && internalVersion.IsPendingPublish)
this.CatalogPropertyLoader.LoadMetaDataContentProperties(accessor, internalVersion);
}
return internalVersions;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment