Skip to content

Instantly share code, notes, and snippets.

@agehlot
agehlot / remove-list-sitecore-items.ps1
Last active September 26, 2022 15:28
Sample PowerShell script to delete Sitecore standard values item and also list out all items that are type of Template.
$templateIds1 = Get-ChildItem /sitecore/templates/Feature/Fortune -Recurse |
? { $_.DisplayName -eq "__Standard Values" } | Remove-Item
$templateIds = Get-ChildItem /sitecore/templates/Feature/Fortune -Recurse |
? { $_.TemplateName -eq "Template" }
@agehlot
agehlot / sendmail.ps1
Created September 24, 2022 08:21
This PowerShell script can be used to send an email or to test SMTP settings of any email service provider i.e. Azure SendGrid.
$From = "[email protected]"
$To = "[email protected]"
$SMTPServer = "smtp.sendgrid.net"
$SMTPPort = "587"
$Username = "apikey"
$Password = "[email protected]"
$subject = "Test Email"
$body = "Test email using SendGrid Email Delivery"
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort)
$smtp.EnableSSL = $false
@agehlot
agehlot / cdp-decision-model-ai-face-recognition.xml
Created September 14, 2022 06:11
Sitecore CDP-DecisionModel: Exported decision model that can be used to auto identify the gender and age on the basis of provided picture url.
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" xmlns:camunda="http://camunda.org/schema/1.0/dmn" namespace="http://camunda.org/schema/1.0/dmn" name="definitions" id="definitions"><decision id="dc3fa009-22ec-40ca-b90d-c487b619b5e8" name="MS Face API"><extensionElements><biodi:bounds x="650" y="336" width="200" height="73.3"/><biodi:edge source="cd7869b0-f5d6-4cff-a2d3-400946bf0e67"/></extensionElements><variable id="variable1578383b-93dc-4ba9-a451-a7b166722ff8" typeRef="map" name="msFaceApi"/><informationRequirement><requiredDecision href="#cd7869b0-f5d6-4cff-a2d3-400946bf0e67"/></informationRequirement><literalExpression expressionLanguage="web-service" id="literal1578383b-93dc-4ba9-a451-a7b166722ff8"><text><![CDATA[{"clientKey":"psfu6uh05hsr9c34rptlr06dn864cqrx","href":"https://api-eu-west-1-production.boxever.com/v2/connections/75a6ed8e-331e-49ad-bac5-13ec081ea729","ref":"75a6ed8e-331e-49ad-bac5-13ec081ea729","name":"MS Face API","descript
@agehlot
agehlot / getAbandonedCartDetails.js
Created September 14, 2022 05:56
Sitecore CDP-Decision model: Programmable to get the list of product in abandoned cart. Previous example was to get the product detail in ul/li but this sample return the product list as an object.
(function () {
function getTriggeredSession(){
if (entity && entity.ref)
for (i=0;i<guest.sessions.length;i++)
if (guest.sessions[i].ref === entity.ref) return guest.sessions[i];
return undefined;
}
@agehlot
agehlot / cdp-send.js
Created September 14, 2022 05:49
Sitecore CDP: DecisionModel: the sample programmable java-script to prepare a payload to trigger Sitecore Send (Moosend). Thanks to brimit for initial code sample.
(function ()
{
var fallbackImage = "https://mydemo.blob.core.windows.net/assets/b98a38c3-b757-5a2d-ad32-cf64c37ef0f5";
var defaultWebsite = '0af7e4acd0454226bcc982ec8de42a38';
var perfumeWebsiteId = '426efbad-a306-4cf2-9071-1a847285773e';
var websiteId = defaultWebsite;
// detect the website by pointOfSale
if (entity && entity.pointOfSale == 'cdn-send-test-pos') {
@agehlot
agehlot / abandonedCartResponse.js
Created September 14, 2022 04:58
Sitecore CDP: Decision Model - Programmable - JavaScript sample to fetch the list of abandoned cart products in ul/li html format
(function () {
function getTriggerSession(){
var sessionRef;
if (typeof entity !== 'undefined' && entity && entity.ref !== 'undefined') {
sessionRef = entity.ref;
}
//print (sessionRef);
var triggerSession;
for (var i = 0; i < guest.sessions.length; i++) {
@agehlot
agehlot / docker-compose.yml
Created September 14, 2022 04:47
XM-Cloud: Customized docker compose file for my xm cloud local instance to adjust target and values.
version: "2.4"
services:
traefik:
isolation: ${TRAEFIK_ISOLATION}
image: ${TRAEFIK_IMAGE}
command:
- "--ping"
- "--api.insecure=true"
- "--providers.docker.endpoint=npipe:////./pipe/docker_engine"
- "--providers.docker.exposedByDefault=false"
@agehlot
agehlot / .env
Created September 14, 2022 04:42
XM-Cloud .env sample file with adjusted SOLUTION_BUILD_IMAGE and NETCORE_RELEASE_IMAGE values. Original values didn't work as my local machine is on Windows 10.
# If you intend to push to a private registry, fill that in here.
REGISTRY=
COMPOSE_PROJECT_NAME=xm-cloud-introduction
# Configure host names, which will be used to configure Traefik proxy routing.
CM_HOST=xmcloudcm.localhost
MVP_RENDERING_HOST=mvp.xmcloudcm.localhost
SUGCON_EU_HOST=sugconeu.xmcloudcm.localhost
SUGCON_EU_HOST_INTERNAL_URI=http://sugcon-eu:3000
SUGCON_ANZ_HOST=sugconanz.xmcloudcm.localhost
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\agehlot> cd D:\Projects\Personal\GitRepo\XM-Cloud-Intro
PS D:\Projects\Personal\GitRepo\XM-Cloud-Intro> .\up.ps1
.\up.ps1 : File D:\Projects\Personal\GitRepo\XM-Cloud-Intro\up.ps1 cannot be loaded. The file D:\Projects\Personal\GitRepo\XM-Cloud-Intro\up.ps1 is not digitally signed. You cannot run
this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
@agehlot
agehlot / ItemSiblingRenderingContentsResolver.cs
Created June 25, 2022 15:24
If you want to customize your JSON rendering response and want complete customized and controlled output with your own logic behind. Here is the solution for you.
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using Sitecore.Data.Items;
using Sitecore.JavaScriptServices.GraphQL.LayoutService;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering.ContentsResolvers;
using Sitecore.Mvc.Presentation;
using System;