Posts

Showing posts from October, 2023

Creating Email Template In Content Hub Programmatically

Image
Hello everyone, In this blog we will see, how we can create mail template programatically in Sitecore Content Hub. So let's quickly try to see the code and we will understand it afterwwards. using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; using Stylelabs.M.Sdk; using Stylelabs.M.Sdk.Models.Notifications; using Stylelabs.M.Sdk.Contracts.Notifications; using Stylelabs.M.Sdk.Contracts.Base; using Stylelabs.M.Sdk.Contracts.Content; using Stylelabs.M.Base.Querying; using Stylelabs.M.Base.Querying.Filters; CultureInfo culture = CultureInfo.GetCultureInfo("en-US"); MClient.Logger.Info($"SS - Creating Email Template"); IMailTemplate template = await MClient.EntityFactory.CreateAsync(Constants.MailTemplate.DefinitionName) as IMailTemplate; template.Name = "MailNotificationReject"; template.SetSubject(culture, "SS Mail Notification Reject"); template.SetBody(culture, "Email...

Running Database Clean Up Task Manually After Sitecore Upgrade in Docker

Hello everyone, In this blog we will see how we can run database clean up task manaully using Sitecore CLI and why it is important especially during upgrade. Recently, we were working on Sitecore upgrade project from 10.1 to 10.3. Our solution was based on Docker setup. If you go through Sitecore Upgrade guide for container, you will find that Sitecore provide mssql-upgrade docker image which takes care of upgrading the SQL schema and tables required for the required Sitecore version to function properly.But if you closely observe during sql upgrade, you will see Sitecore modules are not updated during the process. Sitecore documentation guide provide information how we can upgrade different Sitecore module which is used in the solution. In our solution, we were using Sitecore PowerShell and Sitecore SXA module.Also in Sitecore 10.3, Sitecore is providing this module as Item As Resource( .dat files ) instead Sitecore Items in the package. So whenever we are upgrading, we need to remo...

PowerShell Script to update Alt tag missing for Images

Hello everyone. I am back with another powershell script that can be very useful if you want to update alt tag missing for all images in sitecore.We all know, how important is alt tag from SEO perspective and that's why, this powershell script can come very handy when we have lot of missing alt tag for images. Below is the powershell script for your reference.The script is pretty simple to understand. $rootPathOfImages = "/sitecore/media library/Project/" $testMode = $false $secondsToWaitOnLimitError = 60 $successCount = 0 $errorCount = 0 $errorList = "" $date = Get-Date $formattedDate =$date.tostring('dd-mmm-yyyy-hhmmss') # List of template ids to exclude from processing $excludedTemplateIds = @( "{FE5DD826-48C6-436D-B87A-7C4210C7413B}", #media folder "{0603F166-35B8-469F-8123-E8D87BEDC171}", #pdf "{16692733-9A61-45E6-B0D4-4C0C06F8DD3C}", #doc "{7BB0411F-50CD-4C21-AD8F-1FCDE7C3AFFE}", #...

Creating Custom Component in Content Hub using External Component

Image
Hello everyone, In this blog, we will see how we can add an custom component in Content Hub. We will create a component which will display all related assets based on loaded Asset title. Creating custom component depends on utilizing External Component.So we will follow below steps to achieve the same. We will be using Knockout JS for the implementation. Step1 : Adding External Page Component to Asset Detail Page Step2 : Code Logic implementing Related Asset Component Step 1 Go To Manage Page --> Search Pages --> Search Asset Details. Select Any row and click on add component basically the + symbol. In above screenshot, just click the plus symbol below Related Asset component.A popup will come up. Search for External keywork in search bar and click the result which comes up.Another popup will come and we will give our component a name and enable the visisble checkbox as shown below and click Add.The component will be added to layout. Once the component is added, just c...

Extract Metadata Properties from File and Update Asset fields in Content Hub through Script While Asset Creation

Image
Hello everyone, In this blog, we will see how we can update custom field values define in M.Asset Entity definition, when we add any asset. Let's see the custom field in M.Asset Entity Definition. Here we assume, we are aware, how to add custom fields to M.Asset Schema. Let's get started. Below are the steps that are required to accomplish this process. Step 1: Creating a Metadata Processing Script : This script will be having logic to update the fields. Step 2: Creating an Enitity by uploading a new Asset. Step 3: Verifying the updated values in the Entity newly created. let's start with creating a new script in Content Hub. Click on Manage page section as highlighted below in screenshot in blue. Then search for Scripts in search box. Click on the scripts result and you will be navigated to Scripts page On Scripts click on Add Script button to add a new script. On click a Dialog box will open just give a appropriate script name and choose action as Metad...