Sitecore

How to Configure Synonyms in Solr

To improve search results, one of the easiest way is to add synonyms. For example, a product may have an official name as well as commonly used name. When it is indexed against only the official name because the product name field doesn’t have a commonly used name, typing the …

Sitecore

Dependency Injection Lifetime Management in Sitecore

Sitecore 8.2 and above implements dependency injection based on ASP.NET Core DI. Service registration is handled by using the IServiceConfigurator interface. When we opt for third-party DI modules like Simple Injector, you can have your own customised scoped lifetime. This post is a quick reference for service lifetimes when you …

Sitecore

Implementing Dependency Injection in Sitecore

There are a few different ways to implement dependency injection in Sitecore. Once upon a time, the only way to implementing DI was to use third-party libraries like Simple Injector. Since Sitecore 8.2 release, Sitecore includes build in dependency injection based on Microsoft’s Dependency Injection for ASP.NET Core. We can …

Sitecore

Sitecore 9 Certified Platform Associate Developer Exam Prep Quiz

If you are going for Sitecore certification exam, this exam prep app can help you to pass the exam. It is a micro-front end made by Preact X and TypeScript and the bundle is hosted in GitHub Pages. Source code for this app is here. (1) Quiz Component (2) On …

Sitecore

Creating DbItem with Item ID – Sitecore FakeDb

With FakeDb, we can mock content items. Each tree node can be created by the DbItem class. DbItem class has three constructors as below. public DbItem(string name); public DbItem(string name, ID id); public DbItem(string name, ID id, ID templateId); When your code is calling GetItem with the Sitecore.Data.ID object, you …

Sitecore

How to Troubleshoot FakeDb Errors – Sitecore 8.2

A NuGet package, Sitecore.FakeDb helps us to test functions that use Sitecore API. It is a mock memory database where you can remove the dependencies and isolate the code. When you create a brand-new test project, setting up FakeDb can be tricky. Installing FakeDb and adding the usual two Sitecore …

Sitecore

How to Mock Rendering Parameters in Unit Test – Sitecore

Now that we created a cool components with rendering parameters (see Using Rendering Parameters to Inject Data into Hidden Input), we can write a unit test. Sitecore’s Rendering class has a publicly accessible string field called Parameters. This is the rendering parameter string get populated on page rendering. Mocking is …

Sitecore

Using Rendering Parameters to Inject Data into Hidden Input – Sitecore

What are rendering parameters? They are the additional key-value pair data you can feed to the Sitecore component in addition to data source. The textbook example would be adding an additional CSS class to the component. Content authors can customise the style of the component, like background colour or button …

Sitecore

How to Set up Content Tests with Data Source – Sitecore

Setting up AB tests or even multivariate tests in Sitecore is simple as long as the page is implemented correctly. The key to easily create AB tests is to components. There are a few ways of setting up tests in Sitecore. In this post, let’s create tests by using data …

Sitecore

How to Configure Custom Goals and Trigger them by AJAX Call – Sitecore

Sitecore has out of the box capability to record customers’ behaviours throughout their journey across the channels. We can customise the way to capture customers’ behaviours by registering our own custom events, failure events, goals and outcomes and use them to create personalisation. This out of the box analytics capability …