Skip to content

Instantly share code, notes, and snippets.

@agehlot
agehlot / content-hub-graphql-assets.json
Last active August 13, 2021 09:02
These are some sample Sitecore Content Hub sample GraphQL queries
{
allM_Asset(where: { title_eq: "Group selfie with drinks" }) {
total
results {
fileName
fileSize
isDraft
}
}
}
@agehlot
agehlot / batchUpload.py
Created August 19, 2021 14:29
This python script can be used to upload the orders into boxever CDP via batch API.
# https://developer.boxever.com/reference/overview_batch
# https://developer.boxever.com/reference/importing-the-batch-file
# order data model: https://doc.sitecore.com/cdp/en/developers/sitecore-customer-data-platform--data-model-2-1/sitecore-cdp-order-data-model-for-batch-api.html
# Script takes a file, client key and api secret.Name your JSON file outputFile.json, and compress into outputFile.json.gz
# one JSON record per line, see docs for full details on fomatting
import csv
import json
import uuid
import codecs
@agehlot
agehlot / boxever-guest-search-box
Created September 4, 2021 04:54
Few sample queries that can be used for searching an entity on Guests section.
@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;
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 / .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
@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 / 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 / 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 / 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;
}