The Algolia Search Provider for Sitecore is a powerful integration combining robust content management capabilities with Algolia’s lightning-fast, full-text search engine.
This provider enables Sitecore-driven websites and applications to deliver instant, relevant, and highly customizable search experiences to end-users, ensuring faster content discovery and improved user engagement.
While exploring, I found that Dmitry Harnitski and Peter Procházka have implemented the Algolia Search Provider for Sitecore 9.1 and previous versions. Thank you so much!
I was working on Sitecore SXA 10.3.1 and the workflow was somehow messed up.
Manually modifying can be time-consuming and error-prone. Sitecore SPE is a powerful tool that allows for efficient modification of content in bulk through find and replace text functionality.
In this article, we will explore the steps of using Sitecore SPE to quickly and easily bulk update workflow, streamlining the process, and saving time.
Dry-Run Script:
Running the script won’t make any changes to items, it will give the items that are going to be modified.
I’ve been delving deeper into Sitecore Personalize and have discovered how to incorporate its custom Web Templates into the website.
Let’s dive into the process of creating custom Web Templates and how to utilize them in Web Experiences.
Create Web Template
Let’s navigate to Web Templates in Sitecore Personalize and create it.
The Web Templates have the high flexibility of HTML, CSS, JavaScript, and API tabs to configure.
HTML: Define the structure and content of your web template. This is where you can create the basic layout and elements that will be displayed on your website.
CSS: Style your web template to match your brand’s look and feel. You can add custom styles to ensure that the template is visually appealing and consistent with your website’s design.
JavaScript: Add interactivity and dynamic behavior to your web template. JavaScript allows you to create engaging user experiences by adding features like animations, form validations, and more.
API: Configure API responses to integrate with your organization’s data.
To build the custom web template, let’s say I want to Personalize the About page of my blog.
To create HTML and CSS, we don’t need to dive into the code. A tool called SnipCSS can turn any section of the website into a reusable component.
SnipCSS
SnipCSS is a powerful tool designed to help web developers extract CSS and HTML snippets from any web element or widget. The main key feature is extracting all HTML, images, and CSS with a single click.
Create a separate Authorization in the Identity Server for Forms
Create a Controller to bridge between Custom Submit Action and API call
Set the Custom Submit Action fields
1. Create a separate Authorization in the Identity Server for Forms
Add the FormsServerClient node and its value to the Identity Server’s Sitecore.IdentityServer.DevEx.xml file. After making the change, make sure to IIS Reset for the change to be in effect.
Note: Don’t forget to add transforms for ClientSecret!
Ideally, you can call it in Postman to verify that it’s generating a token using Form’s ClientID and ClientSecret values mentioned in the Sitecore.IdentityServer.DevEx.xml file.
Now that the config is all set to have its own ClientID and ClientSecret, let’s set up the Authorize method with BearerToken specifically for Form’s Identity Credentials.
The SitecoreRestServices handles authenticated HTTP requests to Sitecore’s REST APIs, managing access tokens and retrying requests if authentication fails. It uses dependency injection to configure the HTTP client and obtain the necessary settings.
2. Create a Controller to bridge between Custom Submit Action and API call
Let’s bridge the Custom Submit Action and API call – The CustomController class extends SitecoreController and uses dependency injection to obtain an instance of ICreateAutoPublishService.
It defines a CreateAndPublish method – HTTP POST endpoint that processes CreateAndAutoPublishModel, calls the service to create and publish content, and returns a JSON response indicating success or failure.
The method includes error handling to return appropriate HTTP status codes and messages for different exceptions.
3. Set the Custom Submit Action fields
The final step – Let’s set the Model Type and Error Message based on the class we created.
Publish the form and its related items. It should be good to go!
I encountered a situation that the website was internally facing, which needed a form that would not save the data in the Experience Forms database. Also the data needs to be saved as an Item in the master database so it could be published and consumed in a listing page.
At first, I considered creating a Custom Submit Action to create and publish an item. However, I later realized that the CD server lacked access to the CM server, preventing it from directly generating an item in the master database. So, I came up with the idea of creating a custom API service and combining it with a custom submit action.
Solution
To implement this followed this process
Create Custom Submit Action in Sitecore
Create a code-behind class that inherits SubmitActionBase
Create a secure API that can create and publish an item
Create an API authorization user in the identity server
Create a Controller to proxy between Custom Submit Action and API calls
Set the Custom Submit Action fields
1. Custom Submit Action in Sitecore
Create the custom submit action in the following path /sitecore/system/Settings/Forms/Submit Actions.
2. Create a code-behind class that inherits SubmitActionBase
Create a class that inherits the SubmitActionBase class and overrides the Execute method which calls the API asynchronously to create and publish an item.
The CreateAndAutoPublish class extends SubmitActionBase<string> and is designed to handle form submissions in Sitecore, creating and auto-publishing content items.
It uses dependency injection to obtain instances of IHttpClientFactory, BaseSettings, and ISitecoreRestServices, which are lazily initialized. The ExecuteAction method validates the form submission context and parameters, then calls the Execute method to prepare a model from form fields, serialize it to JSON, and send it to a Sitecore API endpoint using an HTTP POST request.
The class includes helper methods to extract values from form fields and handles errors by logging them and adding them to the form submission context’s error collection.
3. Create an API call that creates and publishes the item
The API call does the following things –
Creates an item under a specified folder
Move and Sync the item into a bucket
Publish the item
Clear the Sitecore cache
Ensure the published item is indexed or force index the item
Clear the Vercel Cache for frontend
In Part 2, we will see how to
Create an API authorization user in the identity server
Create a Controller to proxy between Custom Submit Action and API calls
I had to troubleshoot an issue and started with logs. Since we are in Azure PaaS, I used Kudu or App Service Explorer to search for recent logs. It was absolutely time-consuming.
AzureTools comes to the rescue. It is a simple .aspx page that can be dropped into CM environments, and download logs in seconds.
To pull logs from App Insights, need the Application ID and API Key.
Application ID:
Navigate to the Azure App Insights Resource -> Configure -> API Access.
API Key:
– Create the API Key with Read Telemetry access.
Remember to save the key in notes, you can’t get it after creation!
Now I was excited to download logs –
But then it’s erroring out –
The console is showing the following error –
azuretools.aspx:2082 Refused to connect to ‘https://api.applicationinsights.io/v1/apps/e…ityLevel%2C%20customDimensions.ThreadName%2C%20customDimensions.StackTrace’ because it violates the following Content Security Policy directive: “default-src ‘self’ mailto: tel: ‘unsafe-inline’ ‘unsafe-eval'”. Note that ‘connect-src’ was not explicitly set, so ‘default-src’ is used as a fallback.
It made me curious to check the Web.Config – I couldn’t find the content-src node, added the following line.
I wanted to set up a daily Sitecore content synchronization to lower environments to ensure they are updated with the latest content from Production every morning.
The Sitecore Sidekick PowerShell module came to the rescue – Thank you Jeff Darchuk for the excellent module! One of its key advantages is that it eliminates the need to pass usernames or passwords for higher environments.
P.S. I hope you have the Sidekick module installed, it needs a SharedSecret to communicate to the higher environments.
Content Sync:
After successfully installing the Sidekick PowerShell module, I created the following script to sync the Home page and its children from the Production environment to the QA environment.
Similarly, I created the following script for the Data folder on the SXA site, excluding the Sitewide Configuration item.
Scheduling:
With the scripts ready, I have scheduled both using Powershell Scripts Command to run every 12 hours to fetch items.
The Sitecore Command Line Interface (CLI) is a developer tool that provides a command-line interface to interact with Sitecore instances for serializing templates, layouts, and renderings.
Let’s explore the installation and Configuration on Sitecore 10.x.
To initialize a new project, run the below command.
dotnet sitecore init
Note: Starting from 4.1.0, the sitecore init command takes care of installing default plugins (Sitecore.DevEx.Extensibility.Serialization, Sitecore.DevEx.Extensibility.Publishing, Sitecore.DevEx.Extensibility.Indexing, and Sitecore.DevEx.Extensibility.ResourcePackage).
Skip the below step if you are installing Sitecore CLI 4.1.0 or above.
Download the Configuration files for upgrade <Sitecore 10.3.0 rev. 008463 (upgrade files).zip>
Extract the Sitecore 10.3.0 rev. 008463 (upgrade files).zip file
Scripts Mapping
Now we bunch of files in the extracted folder. We don’t need to run all scripts, Sitecore has given a chart for each Sitecore version upgrade with a list of scripts to run. I’m upgrading from Sitecore 9.3, below is the list of scripts I need to run against clone databases.
Script A – CMS_core_master_web8x.sql
Script B – CMS_core_master_web9x.sql
Script C – CMS_core.sql
Script D – CMS_master.sql
Script E – CMS_web.sql
Script F – SXP_experienceforms_storage.sql
Script H – CMS_security.sql
Core DB:
Run the Scripts C (CMS_Core.sql) for [Your_Project]_Core_Clone DB
<<CMS_core.sql>>
Run the Script H(CMS_Security.sql) against [Your_Project]_Core_Clone DB since I have a separate Security DB connection string.
<<CMS_security.sql>>
Master DB
Run the Scripts D (CMS_Master.sql) for [Your_Project]_Master_Clone DB
<<CMS_master.sql>>
Web DB
Run the Scripts E (CMS_Web.sql) for [Your_Project]_Web_Clone DB
<<CMS_web.sql>>
Experience Forms DB
Run the Script F (SXP_experienceforms_storage.sql) for [Your_Project]_ExperienceForms_Clone DB
<< SXP_experienceforms_storage.sql s>>
Now we ran all the upgrade scripts, let’s update the connection string of vanilla Sitecore 10.3 XM to Cloned databases.
Update the ConnectionString of Sitecore 10.3 XM Instance:
<<ConnectionStrings.config>>
Let’s point to the Clone Databases by updating Initial Catalog and Password.