Skip to content

Instantly share code, notes, and snippets.

@bic742
bic742 / SearchQuery.cs
Last active August 15, 2023 12:04
Extended Sitecore SearchQuery to support sorting and more complex search criteria
using GraphQL.Types;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq;
using Sitecore.ContentSearch.Linq.Utilities;
using Sitecore.ContentSearch.Utilities;
using Sitecore.Data;
using Sitecore.Data.Managers;
using Sitecore.Globalization;
using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch;
using Sitecore.Services.GraphQL.GraphTypes.Connections;
@bic742
bic742 / gist:8a72c914dc8f57fe26df504243565d28
Created August 5, 2021 17:05
Publishing Target Database Configuration
<?xml version="1.0" encoding="UTF-8"?>
<Settings>
<Sitecore>
<Publishing>
<Services>
<DefaultConnectionFactory>
<Options>
<Connections>
<!--This should be the name of the target in Sitecore -->
@bic742
bic742 / docker-compose.yml
Last active March 14, 2022 14:07
Simple example of an MSSQL image, with multiple executions of the mssql-init to initialize and add modules to sql.
version: "2.4"
services:
mssql:
isolation: ${ISOLATION}
image: ${SITECORE_DOCKER_REGISTRY}nonproduction/mssql-developer:2017-${SITECORE_VERSION}
environment:
SA_PASSWORD: ${SQL_SA_PASSWORD}
ACCEPT_EULA: "Y"
ports:
- "14330:1433"
@bic742
bic742 / Find-ProjectAssemblyVersions.ps1
Created January 25, 2023 14:59
This PowerShell script will scan all projects in a given solution for specific assembly and output the project name + assembly version when found. This is intended to be used to locate where a rogue assembly may be coming from in your running environment and get the version aligned with the rest of the system.
$searchPath = "C:\my_repo\src"
$assemblyName = "Sitecore.Horizon.Integration"
$versionPathMap = @{}
$files = Get-ChildItem -Path $searchPath -Recurse |
Where-Object { $_.Name -eq "$assemblyName.dll" }
foreach ($file in $files) {
$versionPathMap.Add($file.FullName, [Reflection.AssemblyName]::GetAssemblyName($file.FullName).Version)
}
@bic742
bic742 / Update-SolutionNugetReferences
Created January 25, 2023 15:01
This script can be used to update all Nuget references in a Helix solution. This is useful for cases where there are many projects and manually updating the references would take a lot of time. This script has to be executed via the Package Manager Console in Visual Studio.
$projects = Get-ChildItem -Path "C:\{solution_dir}\src" -Filter *csproj -Recurse | ForEach-Object { $project = $_; $packages = Select-Xml -Path "$($project.Directory.FullName)/packages.config" -XPath '/packages/package' | ForEach-Object { if ($_.Node.id -like "Sitecore*" -and $_.Node.version -eq "9.1.1") { Install-Package $_.Node.id -Project $project.BaseName -Version "10.2.0" -IgnoreDependencies } } }
$datasource = Get-Item .
$referrers = $datasource | Get-ItemReferrer
$pageOnlyReferrers = $referrers | Where-Object { $_.Name -ne '__Standard Values' } | Sort-Object -Property Name -Unique
$pageOnlyReferrers = $pageOnlyReferrers | Where-Object { $_.Paths.Path -like '/sitecore/content/{site-node}' }
if ($pageOnlyReferrers.Count -eq 0) {
return;
}
@bic742
bic742 / Get-PathsFromTds.ps1
Created August 9, 2023 13:45
This is a PowerShell script that will parse TDS scproj files and generate corresponding SCS module.json files. This process includes consolidation of paths to prevent overly prescriptive configurations. It also supports providing path exclusions to ignore things that should no longer be tracked in a newer tool.
Param(
[string]$srcPath
)
function Invoke-DedupeOutput {
Param(
[System.Collections.ArrayList]$includes
)
$dedupedIncludes = [System.Collections.ArrayList]@()