Skip to content

Instantly share code, notes, and snippets.

private static StartMenu.ApplicationShortcut GetApplicationShortcut(Item item)
{
Assert.ArgumentNotNull((object) item, nameof (item));
LinkField field = (LinkField) item.Fields["Application"];
Assert.IsNotNull((object) field, "link field");
string internalPath = field.InternalPath;
if (internalPath.Length > 0)
{
Item obj = Client.Site.Database.Items[internalPath];
if (obj != null)
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:search="http://www.sitecore.net/xmlconfig/search/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore search:require="Solr" role:require="ContentManagement or Standalone">
<pipelines>
<contentSearch.PopulateSolrSchema>
<processor type="Sitecore.ContentSearch.SolrProvider.Pipelines.PopulateSolrSchema.PopulateFields, Sitecore.ContentSearch.SolrProvider">
<param patch:instead="*[@type='Sitecore.ContentSearch.SolrProvider.Factories.DefaultPopulateHelperFactory']" type="MyNamespace.ExtPopulateHelperFactory" />
</processor>
</contentSearch.PopulateSolrSchema>
</pipelines>
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();