Questions

importante note

##topics

Sitecore JSS/SXA/XM Cloud

  1. Sitecore JSS/XM cloud
  • Layout Service
  • JSON Rendering
  • Content Resolver
  1. Component & Page Creation in Sitecore JSS
  • Partial and Page design
  1. Sitecore SXA feature
  • Rendering variants
  • Scriban template
  1. Theme and Multisite site configuration
  • Custom rendering creation in Sitecore SXA
  • Custom Styling
  1. Sitecore Content serialization
  • using unicorn configuration
  • patch configuration
  1. Personalization
  2. Search Implementation in SXA
  3. Custom Pipelines

Next JS

  1. Build-in Optimization
  2. React Server Component
  3. Data fetching
  4. CSS Support
  5. Client and Server rendering
  6. Server Action
  7. Route Handlers
  8. Redux and routing

.NET

  1. .Net core application
  2. dependecy injection
  3. solid principle
  4. entity framework and data mapping
  5. rest api creation in .NET
  6. Active directry integration

AZURE

  1. Deployment using pipeline
  2. Azure deployment/git/pullrequest/process/branching strategy
  3. Azure ingrastructure
  • On Pre/PAAS/SAAS
  1. Services
  • KUDO
  • APP insight
  • Deployment slot
  • Azure keyvault
  • storage accounts

Create Sitecore pipeline and processor

  1. https://sitecoreinfoexpert.wordpress.com/2016/09/02/the-all-about-sitecore-pipelines-creating-and-extending-pipeline/ (opens in a new tab)
  2. https://archive.doc.sitecore.com/xp/en/legacy-docs/SC70/sitecore-pipelines-sc65-66-a4.pdf (opens in a new tab)

##GraphQL

Create graphql schema

  1. https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-manager/create-graphql-schemas.html (opens in a new tab)

how to write graphql

  1. http://amitkumarmca04.blogspot.com/2021/01/sitecore-graphql-queries.html#gql4 (opens in a new tab)

extend layout service

  1. https://doc.sitecore.com/xp/en/developers/hd/latest/sitecore-headless-development/extend-the-getlayoutservicecontext-pipeline.html (opens in a new tab)

customise rendering output

  1. https://doc.sitecore.com/xp/en/developers/hd/latest/sitecore-headless-development/customizing-the-layout-service-rendering-output.html#creating-an-irenderingcontentsresolver-interface (opens in a new tab)

work topics

  1. performance - added dictionary items to layout service
2. custom content resolver for navigation
using Newtonsoft.Json.Linq;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.LayoutService.Configuration;
using Sitecore.LayoutService.ItemRendering.ContentsResolvers;
using Sitecore.Mvc.Presentation;

public class RecursiveLinkFieldResolver : RenderingContentsResolver
{
    // This override should match the signature required by Sitecore
    public override object ResolveContents(Rendering rendering, IRenderingConfiguration renderingConfig)
    {
        // Attempt to get the data source item manually
        var dataSourceItem = GetDataSourceItemManually(rendering);
        if (dataSourceItem == null)
        {
            return null;
        }

        // Create JSON object structure with recursive child retrieval
        var result = new JObject
        {
            ["items"] = GetChildItems(dataSourceItem)
        };

        return result;
    }

    // Manually get the data source item by using the rendering's DataSource property
    private Item GetDataSourceItemManually(Rendering rendering)
    {
        if (string.IsNullOrEmpty(rendering.DataSource))
        {
            return null;
        }

        // Retrieve the data source item from the context database
        return Sitecore.Context.Database.GetItem(rendering.DataSource);
    }

    // Recursively get all child items and their link field data
    private JArray GetChildItems(Item item)
    {
        var itemsArray = new JArray();

        foreach (Item child in item.Children)
        {
            var childObject = new JObject
            {
                ["name"] = child.Name,
                ["link"] = GetLinkFieldUrl(child, "Link") // Adjust if your field is named differently
            };

            // Recursively add child items if they exist
            if (child.HasChildren)
            {
                childObject["children"] = GetChildItems(child);
            }

            itemsArray.Add(childObject);
        }

        return itemsArray;
    }

    // Helper method to retrieve link field URL
    private string GetLinkFieldUrl(Item item, string fieldName)
    {
        LinkField linkField = item.Fields[fieldName];
        return linkField != null ? linkField.GetFriendlyUrl() : null;
    }
}
  1. create added button to run sitecore powershell script and generate content https://www.youtube.com/watch?v=r94VxfuGlyM (opens in a new tab)
4. created custom graph type - audit log
using GraphQL.Types;
using Sitecore.Services.GraphQL.Schemas;
using System.Collections.Generic;
 
namespace Foundation.GraphQL
{
    public class AuditLogExtender : SchemaProviderBase
    {
        public override IEnumerable<FieldType> CreateRootQueries()
        {
            yield return new WhoAmIQuery();
        }
 
        public class WhoAmIQuery : RootFieldType<UserGraphType, DemoUser>
        {
            public WhoAmIQuery() : base("whoAmI", "Returns the current user.")
            {
                
            }
          
            protected override DemoUser Resolve(ResolveFieldContext context)
            {
                return new DemoUser
                {
                    Id = "1",
                    Name = "John Doe",
                    Email = ""
                };
            }
        }
 
        public class UserGraphType : ObjectGraphType<DemoUser>
        {
            public UserGraphType()
            {
                Name = "DemoUser";
                Description = "Represents a user in the system.";
 
                Field<IdGraphType>("id", "The unique identifier of the user.");
                Field<StringGraphType>("name", "The name of the user.");
                Field<StringGraphType>("email", "The email address of the user.");
            }
        }
 
        public class DemoUser
        {
            public string Id { get; set; }
            public string Name { get; set; }
            public string Email { get; set; }
        }
    }
}   
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
	<sitecore>
		<api>
			<GraphQL>
				<endpoints>
					<master url="/sitecore/api/graph/items/master" type="Sitecore.Services.GraphQL.Hosting.GraphQLEndpoint, Sitecore.Services.GraphQL.NetFxHost" resolve="true">
						<schema hint="list:AddSchemaProvider">
							<audit type="Foundation.GraphQL.AuditLogExtender, Foundation.GraphQL" resolve="true" />
						</schema>
						<gui>true</gui>
						<graphiql>true</graphiql>
						<url>$(url)</url>
 
					</master>
				</endpoints>
			</GraphQL>
		</api>
	</sitecore>
</configuration>
5. integration with typesence/custom event
using Sitecore.Data.Items;
using System;
using System.Threading.Tasks;
using Foundation.SitecoreExtensions.Helper;
using Sitecore.Publishing.Pipelines.Publish;
using Sitecore.Eventing.Remote;
using Sitecore.Publishing.Pipelines.PublishItem;
 
 
namespace Foundation.SitecoreExtensions.Event.Publish
{
    public class PublishEventHandler
    {
 
        public void OnItemProcessed(object sender, EventArgs args)
        {
            if (args is ItemProcessedEventArgs itemProcessedArgs)
            {
                
                var targetDatabase = itemProcessedArgs.Context.PublishOptions.TargetDatabase;
                if (targetDatabase != null)
                {
                    // Get the item from the target database using its ID
                    var publishedItem = targetDatabase.GetItem(itemProcessedArgs.Context.ItemId);
                    if (publishedItem.TemplateID == new Sitecore.Data.ID("{6DB8144E-9270-44C5-8494-F7AEA36FABDA}"))
                    {
                        if (publishedItem != null)
                        {
                            // Handle the published item
                            Task.Run(() => HandlePublishedItem(publishedItem));
                        }
                    }
                }
            }
        }
 
 
        private async Task HandlePublishedItem(Item item)
        {
            if (item == null) return;
 
            // Call Typesense integration logic
            await TypesenseIntegration.ProcessItemAsync(item);
        }
    }
 
}
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
	<sitecore>
		<events>
			<event name="publish:itemProcessed">
				<handler type="Foundation.SitecoreExtensions.Event.Publish.PublishEventHandler, Foundation.SitecoreExtensions" method="OnItemProcessed" />
			</event>
		</events>
	</sitecore>
</configuration>
  1. auditlog class to masure preformance
  2. theme building on cd server using remote events
8. scheduler import/sync items
namespace Foundation.SitecoreExtensions.Commands
{
    public class SyncLiveStreamCommand
    {
        private static string TypesenseApiUrl = "xxx";
        private static string TypesenseApiKey = "xxx";
 
        public void Execute(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule)
        {
            // Fetch data from Typesense and create/update the LiveStream item
            Task.Run(async () => await CreateOrUpdateLiveStreamItem(items[0])).Wait();
        }
    }
}
  1. custom context item resolver to resolve product page/language resolve

General

JSON to jss type generated

  1. https://www.getfishtank.com/insights/automating-typescript-type-generation-for-sitecore-jss-templates (opens in a new tab)

startup

  1. https://sitecoredevservices.com/hire-sitecore-expert-and-developer/#form (opens in a new tab)