Created
May 22, 2016 14:11
-
-
Save casper-rasmussen/b6e09b65f809429ec90526e228502f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseNodeContentBuilder : NodeBuilder | |
{ | |
/// <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 BaseNodeContentBuilder(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.CatalogNode; | |
} | |
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); | |
if (objectId >= 1) | |
{ | |
//Get the first catalog node row with the id requested | |
CatalogNodeDto.CatalogNodeRow catalogNodeRow = this.CatalogContext.GetCatalogNodeDto(objectId, NodeBuilder.NodeResponseGroup).CatalogNode.FirstOrDefault(n => n.CatalogNodeId == objectId); | |
if (catalogNodeRow != null) | |
{ | |
MetaObjectAccessor accessor = new MetaObjectAccessor(objectId, catalogNodeRow.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