Posts

Getting Start With Docker: Part-1

Image
What is Docker? Let's say you created an application and it's working fine on your local machine, but in QA or Prod, it's not working properly. So, it's a common statement that it's working on my machine does not know why it's not working there😊. The reason can be libraries, version mismatch, framework, dependencies or you have upgraded any dependencies to solve the issue and forget, or any other reason and other developer machines and environments do not have all of these. Hence Docker Desktop is an easy-to-install application for your Mac or Windows environment that enables you to build and share containerized applications and microservices using containers. Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. In a container-based approach, the host operating system’s kernel and resources are directly shared by the con...

Sitecore Debugger

Image
After successful implementation of the Sitecore project, page performance comes into the picture in the context of page load time, slowness of page, or rendering. There are many tools available online to investigate the website performance like PageSpeed Insights, JMeter, GTmetrix, Lighthouse, etc., but Sitecore provides its own tool for troubleshooting the Sitecore performance issue i.e., Sitecore Debugger. “If you don’t have a fast website, users will bounce faster you can say. Google recommended page load time is under two seconds, However, speeding up your website is no easy task.”- Google This tool finds out the problems related to slow rendering, and pipeline time is taken and provides the other details for rendering like data source, parameter, Profile, cache setting, output, etc. The debugger facilitates developers to scrutinize the output of both the rendering and the entire page. So that developer can take care of page performance issues while...

Contact Profile Image Using Avatar Facet in Sitecore

Image
Sitecore xConnect provides several default facets like personal information, AddressList, EmailAddressList, etc. Avatar is one of them and it comes under the IContactPicture Legacy facet. If you are new with Sitecore xDB and xConnect and need more insight on the Custom facet, How to create and set/update the facet then you can refer blog post Work with Custom Facet in Sitecore and Create Custom Facet in Sitecore. In this article, I am going to describe how to set the contact picture in the Avatar facet which we can see in the details tab in the experience profile window. private bool SetAvatarFacets(byte[] imageBytes, string mimeType, Contact contact, IXdbContext client) { var pictureData = imageBytes; var pictureMimeType = mimeType; var avatar = contact.GetFacet<Avatar>(Avatar.DefaultFacetKey); //Facet is null if (avatar == null) { avatar = new Avatar(pictureMimeType, pictureData); ...

Uninstall Sitecore Instance Manually

Image
In this blog, I will let you know how to completely remove the Sitecore instance from your machine manually. While installing the new instance we face the error regarding SQL Server, Sitecore Identity Server, etc. To overcome this situation, perform the below steps to entirely clean the old Sitecore instance and you can go with a smooth installation of the new instance. Stop the IIS and remove the configuration: Open the IIS server and in the right panel Action tab click on Stop. Again, in the left panel right-click on the Sitecore instance and choose the Remove option. In the left panel go to the application pool, select all respective Sitecore Instance application Pool and choose the remove option from the right panel. For example, in this blog, I am deleting the "sc1011sc.dev.local" instance. Delete Sitecore Service: Go to the Service window, Press the Win + R key, it will open the run windo...

Lazy Loading in Glass Mapper

Image
Lazy loading is on-demand loading, when users request the content by Lazy loading then instead of loading the whole content on your page it loads only required content, till further request by users. Disable Lazy Loading in Glass Mapper: Individual Get-Item Method All Sitecore Service Methods Individual Get-Item Method: In Sitecore Service Method: var item = _service.GetItem<ICustomModel>("/sitecore/content/Home/Course", x=>x.LazyDisabled()); In MVC Context method: var item = _mvcContext.GetDataSourceItem<ICustomModel>(new GetKnownOptions { Lazy = Glass.Mapper.LazyLoading.Disabled}); All Sitecore Service Methods:  If you don't want to pass x.LazyDisabled() in all the GetItem methods then prefer the Generic Class approach. Create a Generic Class as below: public class RenderingRepository : IRenderingRepository { private readonly IMvcContext _mvcContext; public RenderingRepository(IMvcContext mvcContext) ...

Sitecore Technology MVP Journey 2022

Image
"Rome was not built in a day" , prominent idioms and one of my favorite quotes enthuse me a lot in life. It says, to achieve a long-term goal properly takes a long time and you should not hurry through for it. To get the badge of Sitecore MVP particularly in Technology for me is one of them. My journey for Sitecore MVP begins in the Year 2019. I commenced with Sitecore Technology blogs , actively participate on the Sitecore Stack Exchange Platform and Sitecore Slack Channel . I am honored to be named Sitecore Technology MVP 2022 . I feel fortunate to be participating with a Sitecore Community, Technology, and Product. I am happy that my all efforts and contributions are recognized by Sitecore and Community. My next focus for this year would be: Exploring more in Sitecore Project including Sitecore Content Hub, Docker, Headless, and Jam stack architecture Continuing with sharing and helping others into Sitecore Community. ...

Checkbox Rendering Parameter Taking Null Value If It's Unchecked

Image
Issue: I have a client requirement that each component should be flag-based to turn it on or off. I have used a checkbox in rendering parameters for the implementation of this functionality and applied that rendering parameter template on each component rendering. While reading these values, If I checked the Checkbox IsComponentVisiable it returns "1" and unchecked the Checkbox, it returns me null. var flag= RenderingContext.Current.Rendering.Parameters["IsComponentVisible"] I was surprised about its behaviour that instead of "0" it returns null? I raised the support ticket to Sitecore to understand that am I doing something wrong or if it's the default behaviour of the checkbox field when we use it as the rendering parameter? Sitecore suggested: Find below the Sitecore Team Response on my Ticket: Based on the provided information we would like to define the scope of the current case: Issue def...

URL Redirects Module in Sitecore

Image
In one of my projects, my client's requirement was to implement the URL Redirect feature from his existing SharePoint website to the New Sitecore website. My client suggested the "Constellation.Feature.Redirects"  Redirect module to accomplish the functionality.  In this blog, I am giving insight on this module installation, what features I have used and the challenges I have faced during implementation. I want to give a huge thanks to Richard Cabral aka Sgt Sitecore who guide and helped me with the implementation. Installation: To install the URL redirect module please find below the link in which all the steps are mentioned in detail:  Constellation.Feature.Redirects Steps: Constellation.Feature.Redirects are managed via NuGet. In Visual Studio, fire up the Package Manager console and install it into a Web Application project: PM:> Install-Package Constellation.Feature.Redirects After installation, you must build an...

Pipeline Profiling Processors

Image
Pipeline: It’s a sequence of processes that executes in a defined order to perform the task into Sitecore. In Sitecore, there is a number of inbuild pipelines and we add our custom pipelines into that. We can change the order of the pipelines as per our requirements. When we write our custom pipelines then it’s difficult to find out on deployment environment that it's executing or not. To check the sequence of execution there is a good feature provided by Sitecore is the Pipeline Profiler. The pipeline admin page is used to view all the pipeline processors that are defined into the Sitecore and the sequence in which they will execute. By default, The pipeline Profiler page is disabled, and you need to enable it manually. To enable Pipeline profiling, perform the below listed steps: Add the following key <add key="env:define" value="Profiling" /> to Web.config <appSettings> section. Login into the Sitecor...

Unit Test for Sitecore Custom Personalization Rule

Image
I assume that in your career path you all become chance to hands on implementation for Sitecore Custom Personalization Rule. If you did not, then I have already described in detail about Custom Personalization Rule implementation in my one of previous blog. See the Blog Post: Custom Personalization Rules in Sitecore Today I am going to share with you about implementation of Unit Test for Custom Personalization Rule. Custom Personalization Rule business logic: protected override bool Execute(T ruleContext) { if (_pageContext != null && !string.IsNullOrWhiteSpace(_pageContext.baseketValue)) { var deliveryType = _basketDetailsService.GetBasket(_pageContext.basketValue).deliveryType; if (deliveryType != null && deliveryType== DeliveryType.CashOnDelivery) { return true; } } return false; } In above sample piece of code, I have created two Serv...

Sitecore Custom EXM Unsubscribe Page

Image
If you ever got a chance to implement the email campaign functionality using the default email template in EXM, then you may have observed that each email send to the users contains two links that are Unsubscribe and Unsubscribe from all from future emails campaigns. Requirement: When the user clicks on the Unsubscribe link in the email, instead of redirecting it to Unsubscribe.aspx page which is the default, the user should land on the custom page developed into the Sitecore. On the custom page, the user can choose the options from which list the user wants to unsubscribe. Solution: When the user clicks on the unsubscribe link, Sitecore default redirects to the RedirectUrlPage.aspx with decrypted query string parameter named ec_eq . The ec_eq query string parameter is the encrypted query string, and it is handled by the RedirectUrlPage.aspx process which handles the decryption of those parameters and returns Contact ID, Message-Id and others. On...