Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Sitecore.ContentSearch.SolrProvider.Pipelines.PopulateSolrSchema;
using SolrNet.Schema;
public class ExtSchemaPopulateHelper : SchemaPopulateHelper
{
private readonly SolrSchema schema;
using Sitecore.ContentSearch.SolrProvider.Abstractions;
using Sitecore.ContentSearch.SolrProvider.Pipelines.PopulateSolrSchema;
using SolrNet.Schema;
public class ExtPopulateHelperFactory : IPopulateHelperFactory
{
public ISchemaPopulateHelper GetPopulateHelper(SolrSchema solrSchema) => new ExtSchemaPopulateHelper(solrSchema);
}
using Sitecore.Install.Framework;
using Sitecore.Diagnostics;
using Sitecore.IO;
using System.Linq;
public class CustomPackageInstallationProcessor : IItemInstallerEvents
{
public void OnItemInstalling(object sender, InstallerEventArgs args)
{
Assert.ArgumentNotNull(sender, nameof(sender));
IProcessingContext installationContext = InstallerManager.CreateInstallationContext(this._skipFile);
public static IProcessingContext CreateInstallationContext(bool skipFile = false) => (IProcessingContext)new ExtSimpleProcessingContext(skipFile);
public void InstallPackage(string path, bool registerInstallation, ISource<PackageEntry> source, IProcessingContext context)
{
//..omit for brevity
using (new PackageInstallationContext())
{
@hishaamn
hishaamn / CustomEntrySorter.cs
Created July 14, 2024 09:02
Override current implementation to introduce the SkipFile value
public class CustomEntrySorter : EntrySorter
{
private bool SkipFile { get; set; }
public CustomEntrySorter(ISource<PackageEntry> baseSource, bool skipFile = false) : base(baseSource)
{
this.SkipFile = skipFile;
}
public override void Put(PackageEntry entry)
@hishaamn
hishaamn / ExtSimpleProcessingContext.cs
Created July 14, 2024 08:59
Extend the current Processing Context
public class ExtSimpleProcessingContext : SimpleProcessingContext
{
public ExtSimpleProcessingContext(bool skip)
{
this.SkipFile = skip;
}
public bool SkipFile { get; set; }
}
public class Program
{
public static void Main(string[] args)
{
var filePath = $@"Update filepath of the Package.zip";
ISource<PackageEntry> source = new Sitecore.Install.Zip.PackageReader(filePath);
var packageSinkHelper = new PackageSinkManager();
public class Program
{
public static void Main(string[] args)
{
var filePath = $@"Path to package.zip";
ISource<PackageEntry> source = new Sitecore.Install.Zip.PackageReader(filePath);
var packageSinkHelper = new PackageSinkManager();
public class PackageSinkManager : BaseSink<PackageEntry>
{
public override void Put(PackageEntry entry)
{
Console.WriteLine($"Key: {entry.Key}. Source: {PackageUtils.TryGetValue(entry.Properties, "source")}.");
}
}
public class PackageSinkManager : BaseSink<PackageEntry>
{
public override void Put(PackageEntry entry)
{
// Implementation goes here
}
}