Posts

Showing posts from November, 2022

Understanding Sitecore Role And Virtual User Creation With Use Case

Image
Hello everyone, I am back with another blog. In this blog we will try to understand, how we can create a new Sitecore Domain, how we can create a new Sitecore Role and how we can use the role to restrict the user in backend system from accessing the items in Sitecore. Will try to keep this blog as short as possible. So let's begin. We will try to understand all the above concepts using a use case. This came as a requirement for one of our project. Recently, we got an requirement to restrict some of the logged in user in our website from accessing some of the pages in Sitecore. To overcome this requirement, we have done it by implementing Sitecore Roles and Concept of virtual user in our code behind. Below is the steps which I followed. Step 1: Create a new domain in Sitecore. There are few inbuilt domain which Sitecore automatically provides like Extranet, Sitecore etc. But for our understanding we will create everything new. Go to launchpad once you have logged into Sitecore. In l...

Custom SXA Search Scope Query Token

Image
Hello everyone, In this blog we will see how we can use a custom token in SXA search scope query. What is custom search scope query token and when it is useful. So let's start with understanding what is SXA search scope query token. We all are aware like how search is an important and integral part of any website built using Sitecore. Specially when we are building a website using SXA then most of the time we use Search Result OOTB SXA component for any kind of listing. The Search Result OOTB component primary requirement is Search Scope query. We can build the scope query from Sitecore only where we can define things like Location, Templates etc. Location: Used to help the Solr to get data from specific folder Templates: Used to filter the Sitecore items created from specific templates Many of the time, this suffice to build your search scope query to get the desired results. But we all know, there are times that we need something different from normal scope query to get our resul...

Different ways of Storing Page URL while session expires or User Logout

Hello everyone, In this blog, we will discuss few ways to store last access URL for the users so that we can provide seamless login and same journey for the user.  So recently we got same kind of requirement, where we wanted user to get the last access page if session expires or user is logged out mistakenly. We started exploring different ways. First thing came in mind was to use query string parameter to pass the last access web URL of the page. This works absolutely fine but there are situation where the web page URL can have appended query string parameters. So it will be difficult to pass URL with query string as parameter to login page URL. Also if there are security mechanism like WAF implemented on your website then, there is a high chance it will not allow query string to pass from non-authenticated pages to your controller. This was the same scenario which we were facing. Somehow, the query string was removed automatically while the user was redirecting to login page wh...

Custom Table To Store Sitecore Analytics data in Reporting Database Part 2

Hello everyone, this is continuation to previous blog, Part 1 of this series where we have seen, steps to create custom table in reporting database. Link for the same is here Part 1 This part, we will be concentrating more one the code logic required to update data in the custom table. Let's start with the code part without any delay. We will create 4 classes respectively: CampaignVisitKey.cs : Which will have the key on which the table entry will be done CampaignVisitValue.cs : The value for our columns which will be inserted CampaignVisit.cs : This class is inheriting from Fact table. It merges the current datatable of Campaign visits to existing table CampaignVisitProcessor.cs : This processor executes the actual logic of reading and assigning the values to our model. Let's see the code for all the classes one by one CampaignVisitKey.cs using Sitecore.Analytics.Aggregation.Data.Model; using System; using System.Collections.Generic; using Syste...

Custom Table To Store Sitecore Analytics data in Reporting Database Part 1

Hello everyone, Hope everyone is doing great. This blog is one more addition to my existing blogs list. You can anytime refer my Blog Site for Sitecore related blogs. Hope this blog site will help you in learning something new. Now let's start with todays topic for discussion. In this blog we are going to see how we can create custom table in Sitecore reporting database and how we can write custom aggregation processor to pass all the user define analytics data to our custom tabel similar to how sitecore internally processes the same. This blog will be divided into two parts: We will see how we can create custom table in reporting database along with Store procedure, Table aliases required for the same We will see the custom aggregation code required for the same We will try to understand all this things using a Use Case. Use Case: We need to create a cutom table in reporting db to store all the campaign visited by the Contact along with the dates of visits. Step ...

SXA Variant Token Resolver for Breadcrumb

Image
Hello everyone, I am back with another blog. This time we will discuss something about SXA variant token and how it is useful while creating rendering variants in SXA. We will also discuss a scenario where Variant Token helped us to achieve the required functionality. Let's start without delaying. We were asked to implement a search functionality in SXA. If user search for any keyword, then user must be redirected to search result page where he will be shown all the matched result. So whoever has worked on SXA will be thinking that its simple to implement the required ask using SXA OOTB functionality.  Steps we will be following to achieve the same is: 1. Use the Search Box OOTB component. 2. Configure the required search scope query in Search Box Component 3. Give the Signature and configure the required Search Result Page where the user should be redirected, when someone search for something. 4. On the Search Result Page where we are showing the user all matched results, we will ...

Sitecore SXA 10.2 installation with SXA Solr Core

Image
Hello Everyone. This is continuation to my previous blog where we have seen how we can install Sitecore 10.2 using windows PowerShell. You can check the blog here  Sitecore 10.2 Installation .  So let's start and see how we can install SXA. To install SXA we need to download SXA compatible module for Sitecore 10.2. Get the relevant SXA package from Sitecore website. The compatible version to SXA.10.2.0. Install the SXA PowerShell first and then proceed with SXA package from install package option from Sitecore control panel. Now need to add Solr SXA core. Duplicate Sitecore_master_index and Sitecore_web_index. Rename the duplicated Sitecore_master_index to Sitecore_sxa_master_index. Rename the duplicated Sitecore_web_index to Sitecore_sxa_web_index Open the Sitecore_sxa_master_index and edit the core properties with your Solr index name. Open the Sitecore_sxa_web_index and edit the core properties with your Solr index name. Once done update the same name in below config file. ...

Sitecore 10.2 Installation using Windows PowerShell

Image
Hello everyone. Another blog post is here. This time we will see, how we can install Sitecore 10.2 locally using Windows PowerShell. Before proceeding for installation, there are some software's which will be required to be installed on system. Required Software: Visual Studio 2019 SQL server 2017 and above .NET  Framework 4.8 and above Once installed, we can proceed with Sitecore 10.2 installation. Step 1: Open Windows PowerShell (run as administrator) Step 2:  Run Command:   Set-ExecutionPolicy -Scope CurrentUser Unrestricted and Select Y Step 3:  Check if SIF framework is available:  Get-Module -Name SitecoreInstallFramework -ListAvailable Step 4: I f 2.3.0 is available, skip step 5 Step 5: If yes, then check the version. For Sitecore 10.2 the version should be 2.3.0. If 2.3.0 is not available then update your SIF version using command:  Update-Module SitecoreInstallFramework -force Step 6:   Now Enable the Co...

Different ways to rebuild and refresh Solr Indexes

Hello Everyone, I am back with another blog. This time we will discuss how we can rebuild our Solr indexes programmatically. What is the difference between Solr force index rebuild and Solr index refresh. How we can achieve Solr index refresh programmatically. So let's start with the same without wasting any time. We all are aware that we can rebuild our indexes from Sitecore control panel. Sitecore also provides the option to rebuild a tree instead of rebuilding whole index from ribbon. But if we want to rebuild our indexes programmatically the how we can do it. Also if we don't want to rebuild the whole index, is there any way programmatically we can refresh the index for specific path or folder. Let's understand first, difference between the two first and see the code accordingly. 1. Sitecore Index Rebuild:     Whenever we do a rebuild index, Solr deletes the indexed files from its data folder and again recreates it from scratch. 2. Sitecore Index Refresh:     Whe...

Smart Error Handle Mechanism For Sitecore Rendering Components

Image
Hello Everyone, I am back with another blog. In this blog we will discuss how Sitecore handle exceptions internally while rendering the the Sitecore components on the page. What error handling strategy it use internally and which pipeline is responsible for it. How we can pass our custom handler to existing pipeline processor. We might have faced situations like, when exception occurs in any one component, it breaks the whole page and page is redirected to the custom error page defined. We know, we can handle such scenario by writing proper try catch mechanism and handle the exceptions. But sometime it happens, we don't handle all type of exceptions properly which can lead to breaking of that page.  So let's start, how we can handle it for all Sitecore component in one go if exception handling is not done properly. First we will see what is default pipeline to render the component and error strategy defined. If we see in below image, there is a processor called Sitecore.Mvc.Pi...