Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label CMS. Show all posts
Showing posts with label CMS. Show all posts

Sunday, December 29, 2024

Sitecore 10 .NET Developer Certification Exam: My Experience and Key Takeaways

Sitecore 10 certification


In December 2024, I cleared the Sitecore 10 .NET Developer Certification Exam, an essential milestone for developers working in the Sitecore ecosystem. This blog will walk you through my experience, the exam structure, preparation tips, and new questions that were included, which might help you prepare better.

Exam Structure
• Total Questions: 60
• Duration: 120 minutes
• Key Topics: No questions on ASP.NET Core, but the exam extensively covered: 
o Sitecore xConnect
o xDB
o Sitecore Search and Indexing
o Sitecore Marketing Features

The questions were mostly multiple-choice and focused on practical scenarios, with several around the newer features in Sitecore. Here are new questions that they asked

1. What are the things required for Sitecore reporting?
a. Reporting API 
b. Reporting services
c. Processing server
d. Reporting database

2. Whats the role of xConnect search collection?
a. Search the interaction

3. If you have to create a new model for xDB, what's the next step?
a. Create JSON file for model and deploy to xConnect project folder

4. What are the available options for IQuarable<Item> for search operations
a. GetResults
b. GetFacets
c. Where, orderby, contains
d. Groupby, sum

5. How to show same price for all version of each language in Sitecore item?
a. Make field Unversioned

6. What is the use of goals in Sitecore?
a. Measure the engagement and tracking

7. From the personalization rule what can be achieved
a. Hide the component,

         b.  Replace the layout of the component

8. New language is not available from available language list in Sitecore, how can you add new language?

a. Add new language from control panel

9. What is the use of <IncludeTemplate> in config file for search indexing 

a. Indexing include only those items created from specific template

10. What can be achieved from Sitecore search operation

a. Search the products

11. How can you change the alt value of items that contains image field

Get the items, get all fields collection and change the alt field 

13. What the use of “Item Include” in serialization file?

a. Specify the item path that need to serialise

14. Which of the following information is available within Workbox?

A. Number of editable data source items in all of Sitecore

B. Information about an item's originating template

C. Number of active campaigns divided by marketing team

D. Available workflow commands divided by associated workflow.

15. Which statement characterizes the Sitecore Extranet security domain?

A. It provides default access to the Sitecore identity server for users to log in to the appropriate environment areas.

B. It is an internal security domain for users that can access the Sitecore client tools and editing functionality.

C. It is the domain that contains user accounts as well as customized roles for managing read access to the website content.

D. It provides customized roles for controlling access to third-party environments such as a CRM or payment portal.

16. For non-SXA websites, why is it recommended to avoid setting presentation details directly on new content items?

A. Defining presentation details on standard values ensures all the fields related to an item's presentation are configured for access by content creators.

B. Sitecore does not allow presentation details to be changed at the content-item level, so they must be set and edited from the standard values of templates.

C. It allows all content items made from the same template to have the same presentation details by default and eliminates additional work during content creation.

D. It forces a prompt to appear when new content items are created so Content Authors can finalize the presentation details for the new content items.

17. Of the available options, which is a purpose of the field source in data templates?

A. The field source is a field property that designates where in the content tree the field obtains its data.

B. The field source is used to control a user’s access and permissions to folders and files in the content tree.

C. The field source defines how a field’s data appears in the Content Editor in the UI.

D. A field source maps a field to the underlying class representation in the API.

18. What is a reason to set the insert options on a specific item under the content node of the content tree?

A. To allow Content Authors to insert items into the content tree for all the templates they have access to

B. To allow Content Authors to insert items under the specific item in addition to what is included with the item's standard values

C. To allow Content Authors to insert new items under any item within the content tree

D. To allow Content Authors to insert items created from any system template into the content tree under the specific item

19. Your published layout.cshtml file contains a static placeholder with a “main” placeholder key and you want to add renderings to the presentation details of a templates standard values; however you cannot see the "main" placeholder key you added to the layout. Of the available options, which is the best explanation of what happened?

A. There is a missing configuration element in web.config for placeholders.

B. The wrong layout is associated with the current template.

C. A Sitecore publish is required to show placeholder keys when editing presentation details.

D. There is no placeholder settings item for the associated "main" placeholder key.

Preparation Tips

1. Video and PDF by Navan

I found the video and PDF tutorials by Navan extremely helpful. He comprehensively covered the topics and ensured I had a clear understanding of the Sitecore core concepts. PDF is available at here.

2. Focus Areas Beyond the Basics

Pay special attention to xConnect, xDB, and Marketing features, as these were prevalent in the exam.

3. Hands-On Practice

Create a small Sitecore project to familiarize yourself with search operations, workflows, goals, personalization rules, and field properties like "Unversioned" and "Shared."

Final Thoughts

Passing the Sitecore 10 .NET Developer Certification Exam requires a combination of practical experience, theoretical knowledge, and focused preparation. Be thorough with advanced topics like xConnect and xDB, as they often differentiate a prepared candidate from the rest. With the insights and preparation resources shared here, you’ll be better equipped to tackle the exam successfully.

Good luck to all aspiring Sitecore-certified developers!

Thursday, October 26, 2023

Whitepaper : Sitecore Pipeline

Pipeline in general
Pipeline in general

In programming, a pipeline is a concept used to describe a sequence of data processing elements or functions that are connected in a chain, where the output of one element serves as the input for the next element. This technique is commonly used to organize and streamline the flow of data or operations in various computational processes.

Pipeline Flow
Pipeline Flow


In a pipeline, data flows through different stages or processing units, with each stage performing a specific operation on the data. Each stage typically focuses on a particular task, and the combination of all stages allows for complex data processing or transformations to be achieved efficiently.

The pipeline pattern is widely used in various areas of software development, such as data processing, data analysis, and even web application development.

 

Examples of Pipelines

 

Data Processing Pipeline: In data processing, a pipeline might involve several stages for transforming and analyzing data. For example, in a data analysis pipeline, data could flow through stages like data ingestion, cleaning, feature extraction, machine learning model training, and finally, result evaluation.

Image Processing Pipeline: In image processing, a pipeline could be used to process images through various stages, such as image resizing, noise reduction, color correction, edge detection, and image enhancement.

Web Development Pipeline: In web development, a pipeline can be used for tasks like asset compilation and optimization. For instance, a pipeline could involve concatenating and minifying CSS and JavaScript files, optimizing images, and caching assets for faster loading times.

Continuous Integration/Continuous Deployment (CI/CD) Pipeline: In software development, a CI/CD pipeline automates the process of building, testing, and deploying code changes. This pipeline might include stages like code compilation, unit testing, integration testing, and finally, deployment to production servers.

Natural Language Processing (NLP) Pipeline: In NLP, a pipeline could be employed to process text data through various stages, such as tokenization, part-of-speech tagging, named entity recognition, sentiment analysis, and text summarization.

Audio Processing Pipeline: In audio processing, a pipeline might involve stages for audio file decoding, noise reduction, audio feature extraction, speech-to-text conversion, and text-to-speech synthesis.

Video Editing Pipeline: In video editing, a pipeline could include stages like video clipping, adding special effects, transitions, audio synchronization, and video rendering.

These examples demonstrate how pipelines can be used to break down complex tasks into manageable steps, where each step in the pipeline performs a specific operation, and the output of one step serves as the input for the next step. This modular approach to programming allows for easier development, testing, and maintenance of software systems.

 

Introduction of Sitecore Pipeline

 

Sitecore Pipeline is a fundamental concept of the Sitecore CMS architecture. It's a way of defining a sequence of steps that execute in a particular order to handle specific events or processes within the Sitecore request processing lifecycle. This approach allows for highly extensible and modular development of Sitecore solutions.

In this article, I will provide an in-depth look at Sitecore Pipeline with practical examples of how to leverage this architecture to extend and customize Sitecore functionality.


Understanding Sitecore Pipeline

Before diving into Sitecore Pipeline, it's essential to understand the Sitecore request processing lifecycle. Sitecore request processing lifecycle has various stages, and each stage is a specific event that occurs within Sitecore.

When an HTTP request arrives at a Sitecore website, the request is processed through various stages before rendering a response. Each stage consists of one or more pipelines, and each pipeline consists of one or more processors.

A processor is a C# method that executes a specific operation or handles a particular event within the request processing lifecycle. The processor can modify the request, perform additional operations or even prevent the request from proceeding to the next stage of the lifecycle.


Sitecore Pipeline Architecture

Sitecore Pipeline architecture is based on the idea of a sequence of processors that execute in a specific order. The sequence of processors is grouped into a pipeline. Each pipeline executes at a specific stage in the Sitecore request processing lifecycle.

Pipeline and Processors
Pipeline and Processors


Few types of pipelines in Sitecore are:

InitializePipeline - Executes when an Sitecore instance start.

HttpPipeline - Executes when an HTTP request is made to the Sitecore website.

PublishPipeline - Executes when the Sitecore items are being publish.

Each pipeline consists of a sequence of processors that execute in a specific order. These processors can be Sitecore-built-in processors, custom processors, or a combination of both.


Creating Custom Processors

Creating custom processors is a straightforward process. You create a C# method that performs the operation you want and then add it to the pipeline.

The first step is to define the pipeline where the processor will execute. You can add a processor to an existing pipeline or create a new pipeline.

Once you have identified the pipeline, you will define the processor. In this step, you will create a C# method that performs the operation you want.

After defining the processor, you will register it with the pipeline. You can register the processor at the beginning or the end of the pipeline or somewhere in between.


Best Practices for Sitecore Pipeline

Here are some best practices to keep in mind when working with Sitecore pipelines:

Plan Your Pipeline Carefully: Plan your pipeline carefully to ensure that processors execute in the correct order and that they do not conflict with each other.

Keep Your Pipeline Simple: Keep your pipeline simple by breaking it down into small, reusable processors.

Use Sitecore-Built-in Processors: Whenever possible.


Pipeline Examples

Now that we have a good understanding of how pipelines work, let's take a look at some examples of how we can use pipelines to perform specific tasks.

 

1.      Http Request Processor for Page not found

 

This example shows that how to create custom Page not found for Sitecore website.

 

using Sitecore.Data.Items;

using Sitecore.Pipelines.HttpRequest;

 

namespace AlexaSearch.Pipelines

{

    public class HttpRequestProcessor404 : HttpRequestProcessor

    {

        public override void Process(HttpRequestArgs args)

        {

            if (Sitecore.Context.Item != null || Sitecore.Context.Site == null || Sitecore.Context.Database == null

                || Sitecore.Context.Database.Name == "core"

                || args.RequestUrl.AbsoluteUri.ToLower().Contains("/sitecore/api/layout/render/jss")

                || args.RequestUrl.AbsoluteUri.ToLower().Contains("/sitecore/api/jss/import")

                || args.RequestUrl.AbsoluteUri.ToLower().Contains("/api/sitecore/"))

            {

                return;

            }

 

            var alexa404PageId = Sitecore.Configuration.Settings.GetSetting("Alexa404");

            var pageNotFound = Sitecore.Context.Database.GetItem(alexa404PageId);

            if (pageNotFound == null)

                return;

            args.ProcessorItem = pageNotFound;

            Sitecore.Context.Item = pageNotFound;

            args.HttpContext.Response.StatusCode = 404;

        }

    }

}

 

Web.config entry

<pipelines>

                                       

             <httpRequestBegin>

                           <processor type="AlexaSearch.Pipelines.HttpRequestProcessor404,AlexaSearch"

                          patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']"/>

            

             </httpRequestBegin>

 

 

2.      Item Processed Processor for Publish Items

 

This example shows that how to create processor to get publish items and logging their activities.

 

using Sitecore.Data.Items;

using Sitecore.Diagnostics;

using Sitecore.Publishing.Pipelines.Publish;

using System;

using System.Collections.Concurrent;

using System.Collections.Generic;

using System.Linq;

using System.Web.UI;

 

namespace AlexaSearch.Pipelines

{

    public class ItemProcessedProcessor : PublishProcessor

    {

        public override void Process(PublishContext context)

        {

            if (!context.Aborted)

            {

                var publishItems =  context.ProcessedPublishingCandidates.Keys;

                foreach(var tempItem in publishItems)

                {

                    var currentItem = context.PublishOptions.TargetDatabase.GetItem(tempItem.ItemId);

 

                    if(currentItem != null)

                        Sitecore.Diagnostics.Log.Info("My Publish item is " + currentItem.Name, this);

                }

            }

        }

    }

}

 

Web.config entry

<pipelines>

                                       

             <publish>

                           <processor patch:after="*[@type='Sitecore.Publishing.Pipelines.Publish.ProcessQueue, Sitecore.Kernel']" type="AlexaSearch.Pipelines.ItemProcessedProcessor, AlexaSearch" />

             </publish>

 

3.      Log Request Begin processor

 

This example shows that how to log HttpRequestBegin pipeline activities.

 

using Sitecore.Pipelines.HttpRequest;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

 

namespace AlexaSearch.Pipelines

{

    public class LogRequestBegin

    {

        public void Process(HttpRequestArgs args)

        {

            Sitecore.Diagnostics.Log.Error(DateTime.Now + " Hello HttpRequestBegin pipeline executed ", this);

        }

    }

}

 

Web.config entry

<pipelines>

                                       

             <httpRequestBegin>

                           <processor type="AlexaSearch.Pipelines.LogRequestBegin, AlexaSearch" /> 

             </httpRequestBegin>

 

4.      Custom Field Processor

 

This example shows that how to capture each fields in processor. It will check for rich text field and append extra text at the end of rich text field content.

 

using Sitecore.Pipelines.RenderField;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

 

namespace AlexaSearch.Pipelines

{

    public class MyCustomFieldProcessor

    {

        public void Process(RenderFieldArgs args)

        {

            if (!(args.FieldTypeKey == "rich text"))

                return;

            args.After = "<div><h3>Copyright Alexa</h3></div>";

        }

    }

}

 

Web.config entry

<pipelines>

                                       

             <renderField>

                           <processor  patch:after="processor[@type='Sitecore.Pipelines.RenderField.GetTextFieldValue, Sitecore.Kernel']"

                                                     type="AlexaSearch.Pipelines.MyCustomFieldProcessor, AlexaSearch" />

             </renderField>

 

5.      Set Default Alternate Text in media item

 

This example shows that how to Set Default Alternate Text in media item.

 

using Sitecore.Diagnostics;

using Sitecore.Pipelines.GetMediaCreatorOptions;

 

namespace AlexaSearch.Pipelines

{

    public class SetDefaultAlternateTextIfNeed

    {

        public void Process(GetMediaCreatorOptionsArgs args)

        {

            Assert.ArgumentNotNull(args, "args");

            if (!string.IsNullOrWhiteSpace(args.Options.AlternateText))

            {

                return;

            }

 

            args.Options.AlternateText = GetAlternateText(args);

        }

 

        protected virtual string GetAlternateText(GetMediaCreatorOptionsArgs args)

        {

            Assert.ArgumentNotNull(args, "args");

            if (string.IsNullOrWhiteSpace(args.Options.Destination) || args.Options.Destination.IndexOf("/") < 0)

            {

                return string.Empty;

            }

 

            int startofNameIndex = args.Options.Destination.LastIndexOf("/") + 1;

            return args.Options.Destination.Substring(startofNameIndex);

        }

    }

}

 

Web.config entry

<pipelines>

                                       

             <getMediaCreatorOptions>

                           <processor type="AlexaSearch.Pipelines.SetDefaultAlternateTextIfNeed, AlexaSearch"/>

             </getMediaCreatorOptions>

 

What is CorePipeline.Run()


CorePipeline.Run() is used in Sitecore when you want to execute a pipeline programmatically. Pipelines in Sitecore are used to execute a series of processors in a specific order. They are defined in configuration files and are typically triggered by specific events or user actions.

Here are some situations where you might want to use CorePipeline.Run():

Implementing custom business logic: If you have custom business logic that needs to be executed as part of a Sitecore pipeline, you can create a new pipeline and use CorePipeline.Run() to execute it.

Modifying the behavior of existing Sitecore pipelines: If you need to modify the behavior of an existing Sitecore pipeline, you can add your own processor to the pipeline and use CorePipeline.Run() to execute it.

Triggering pipelines programmatically: If you need to trigger a pipeline programmatically, for example in response to a user action, you can use CorePipeline.Run() to do so.

Integrating with third-party systems: If you need to integrate Sitecore with a third-party system that requires custom processing, you can create a new pipeline and use CorePipeline.Run() to execute it.

Example

 

using Sitecore.Pipelines;

using System;

 

namespace AlexaSearch.Pipelines

{

    public class MyCustomPipelineArgs : PipelineArgs

    {

        public string CustomValue { get; set; }

    }

 

    public class MyCustomPipelineProcessor

    {

        public void Process(MyCustomPipelineArgs args)

        {

            Sitecore.Diagnostics.Log.Error(DateTime.Now + " My Custom Pipeline Processor " + args.CustomValue, this);

        }

    }

}

 

Call this pipeline from some Views as

@{

            var args = new AlexaSearch.Pipelines.MyCustomPipelineArgs { CustomValue = "Hello, World!" };

            Sitecore.Pipelines.CorePipeline.Run("myCustomPipeline", args);

}

                          

                           <div>

                                        <p>=====================================================</p><br>

                                        This is my Footer Component<br>

                                        <p>=====================================================</p><br>

                           </div>  

 

Web.config entry

<pipelines>

                                       

             <myCustomPipeline>

                           <processor type="AlexaSearch.Pipelines.MyCustomPipelineProcessor, AlexaSearch" />

             </myCustomPipeline>

 

Monitor Sitecore pipelines

 

There are a few ways to monitor Sitecore pipelines:

Log files: Sitecore writes detailed log files that can be used to monitor pipelines. By default, Sitecore logs are located in the App_Data/Logs folder. You can configure the logging level in the Sitecore configuration file to get more detailed information.

Debug mode: You can also monitor pipelines in debug mode by setting breakpoints in your custom pipeline processors and stepping through the code. This can be useful for troubleshooting issues or testing new pipeline functionality.

Pipeline Profiler: It is a Sitecore tool that helps developers to monitor the performance of pipelines in real-time

 

Pipeline Profiler

Pipeline Profiler
Pipeline Profiler

Pipeline Profiler is a Sitecore tool that helps developers to monitor the performance of pipelines in real-time. It is a visual representation of the Sitecore pipeline events that occur during an interaction with a website, such as page rendering or a form submission.

The Pipeline Profiler can be accessed it from /sitecore/admin/pipelines.aspx. It displays the execution time for each pipeline and the time taken by each processor within that pipeline. This information can be used to identify performance bottlenecks in the pipeline and to optimize pipeline execution.

 

Advantages of Sitecore Pipeline:

 

Flexibility: Sitecore pipelines provide a flexible way to add, remove, or modify functionality at different stages of a process. This allows for customizations without impacting the existing codebase.

Reusability: Since pipelines are modular, they can be reused in different contexts, making development faster and more efficient.

Maintainability: Separating code into smaller, more manageable pieces makes it easier to maintain and debug.

Extensibility: Pipelines can be extended with new processors to meet changing business requirements.


Disadvantages of Sitecore Pipeline:

Overhead: Pipelines can add some overhead to processing times, especially if there are many processors involved.

Complexity: Understanding the Sitecore pipeline model and how to work with it can be complex and requires some experience.

Performance: While pipelines can be used to optimize performance, if not implemented carefully, they can have a negative impact on performance.

Debugging: Debugging pipeline issues can be challenging because of the number of processors involved and the complex interactions between them.

 

When not to use Sitecore pipelines?

While Sitecore pipelines offer a lot of benefits, there are some situations where they might not be the best fit. Here are some cases where using pipelines may not be ideal:

Simple, straightforward tasks: If a task is simple and straightforward, it may not require the use of a pipeline. For example, if you only need to update a single item, you could do that directly without creating a pipeline.

Performance-critical tasks: While Sitecore pipelines are very flexible and powerful, they do have some overhead associated with them. If you have a task that needs to be performed as quickly as possible, using a pipeline may add too much overhead and slow things down.

Tight coupling between components: If components within your application are tightly coupled, it may not make sense to use a pipeline. Pipelines are designed to loosely couple components, so if there is already a tight coupling between the components, adding a pipeline may just add unnecessary complexity.

Inflexible requirements: If the requirements for a task are very rigid and not likely to change, it may not make sense to use a pipeline. Pipelines are designed to be very flexible and adaptable, so if the requirements are unlikely to change, you may not need that level of flexibility.


Conclusion

In this article, we have explored the Sitecore pipeline framework and how it can be used to perform various tasks in Sitecore. I have covered the basics of how pipelines work, how to configure them in Sitecore, and some examples of how they can be used.

By understanding the Sitecore pipeline framework and how to use it effectively, developers can create more powerful and flexible solutions in Sitecore. With this knowledge, you will be able to leverage the pipeline.