Sitecore 9.3 Installation – Setup in Local Developer Machine

Sitecore 9.3 was released on November 28th and it’s cool as ever. Sitecore SXA 9.3 has also been released along with Sitecore Experience Platform 9.3 and several other suite of Sitecore Products. More about Sitecore 9.3 key upgrades and other Sitecore Products can be found in the official Sitecore Page. I am planning on sharing my experience with these new upgrades and how one can leverage them, in my upcoming posts.

Installation.

Phew….Sitecore 9.3 XP Single package comes up with Sitecore Install Assistant – an GUI Based Sitecore setup. I haven’t tried installing Sitecore 9.2. Having said that, after 9.1 installation experience ,9.3 installation is the smoothest and time saving as well.

While installing 9.1 we had to run a lot of PowerShell scripts, setup Solr on our own and setup solr as service and certificates etc.

Guess Sitecore understood the pain area and worked on it.

IN this post, I will share my experience on installing 9.3 using the Sitecore Install Assistant.

First, download the Graphical Setup package for XP Single.

Download options for On Premises deployment 
Graphical setup package for XP Single 
The Sitecore Install Assistant's user interface guides you through the Sitecore XP Developer Workstation (XP Single) installation. 
Use it to review system requirements, install prerequisites, and complete the entire installation process.

Extract the package and you will find the setup file, RUN the setup file to launch the Sitecore Install Assistant

On Sitecore 9.1, we would have downloaded the Sitecore Install Framework using PowerShell.  The SIA takes care of the all the prerequisites.

Once, all the prerequisites are downloaded, SIA provides us options to Install 8.1.1 optionally or we can also install Solr on our own and provide the necessary config. Make sure the port you provide here is free and it is not used by any other program.

Once this Step is completed, Solr will be installed in your local and it will created as a windows service. You can verify it by accessing and by checking the windows service.

These are self explanatory.

Fill in the SQL Database details.

Next fill in the Solr details. If you have skipped installing you can provide your solr config details here.

Sitecore provides at additional option to install Sitecore SXA 9.3

The Next screen allows you to check the configs.

Finally, once everything is done, Sitecore validates the provided configs. Once, done you can click Install.

Installation will be in two parts – Sitecore Web Deploy and SXA Deploy

Click Next and then Launch the Sitecore Site.

As much as it may be, but installing Sitecore 9.1 gives you more insight. It would give you a better understanding of all those behind the screen tasks being done here. 92 tasks in the Installation part 1, setting up Identity Server, XConnect  running the marketing automation and other services you can see these logs while installing via  PowerShell – Sitecore 9.1.

Even for 9.3 once installation is complete I would recommend one to go through the Sitecore Installation logs. It gives you a better insight of what’s happening in the back.

Remember:

  • Sometimes IIS might get stopped after Solr installation we might need to restart it manually.

Sitecore Command – Compress Image in Sitecore

In our previous post we saw how we can use Sitecore Task Scheduler to read an RSS Feed and sync items in the Sitecore content tree.

In this post, we will work on creating a custom button for media items that compresses the images with our custom image compression logic.

Media Library 
Default Website 
Experience Explorer 
Featu 
Files 
Founc 
Image 
prc 
Projex 
Systet 
Exten 
Content Editor 
Insert 
Search 
Compress 
Duplicate 
Delete 
Rename 
Copying 
Sorting 
Edit 
Experience Editor 
Publish Item 
Console 
Scripts 
Refresh

This article is intended to demonstrate the use of a Sitecore Custom Command and how it can be extended. Hence, I have added a very simple compression logic. However, the logic can be extended to different requirement.

Also, if you are planning on optimizing the Media Items in entire Sitecore Media Library, you should have a look at https://kamsar.net/index.php/2014/07/automatic-sitecore-image-optimization-with-dianoga/

To create a Custom Command, we will first be adding the command name in a config as a patch and map that command to a class name/assembly.

To create a custom command, we need to have a class that extends  Sitecore.Shell.Framework.Commands.Command and overrides it’s Execute method. So that, once that command is triggered the control will be passed to this method with the Context Item.

It is a best practice to create all our Custom Commands in a single config file and place them in the App_Config folder.

PC New Volume (D:) > Websites Markl > scg10.sc > App_Config 
Name 
SitecoreCustom.Commands.config 
Date modified 
11/1/2019 12:15 PM 
> Include > Z.Foundation 
Type 
XML 
1 KB

The Name we give for the command is the key here. This same “contentimage:compress” will be updated in the message field of the relevant item we create.

In this scenario, we will accomplishing the image compression by adding a new button – Compress under the Context Menues. To add a new item under Context Menu, we need to create a Menu Item in Core Database under “/sitecore/content/Applications/Content Editor/Context Menues/Default”. We will name it as Compress.

Content Editor 
Applications 
Context Menues 
Default 
Insert 
Search 
Compress 
Divider 3 
cut 
Copy 
Paste 
Divider 2 
Duplicate 
Delete 
Rename 
Divider I 
Copying 
Compress 
Quick Info 
Item ID: 
Item name: 
Item path: 
Template: 
Created from: 
Item owner: 
Action [shared): 
{091 CSS02-8997-4E3F-94F&609500E051 B9) 
Compress 
/sitecore/contentJApplications/Content Editor/Context Menues}Default/Compress 
/sitecore/tempIates/System/MenusJMenu item (998B965E6AB84568-810F8101 D60DOCC3} 
[unknown] 
sitecore\Admin

Now, we can update the relevant fields – Display Name and Message. Display Name is the name of the option displayed in the Menu and Message is the command name (The Name we have give in the command config patch)

Display name [unvers.onedl: 
Compress 
Hotkey LunversionedJ: 
Icon (shared]: 
Open icon 
ID [shared]: 
Clear 
Message [shared):

Now, let’s move on to the logic part.

Here, when the compress option is clicked, we will read the context item(Media Item) and then it’s image, convert it to a stream, use System.Drawing namespace and it’s associated methods to compress the image, reducing it’s size without losing it’s quality. Once that image is compressed, it will  created as a new Sitecore Media Item and will be added back to the Sitecore Media Library. Again, the image compression logic can be created based on any compression algorithms. To support this, we are converting the image to a stream. This stream can be passed on to any image compression algorithms and can be processed further.

O rete 
public cla55 : Connand 
/ 'Trying it via Command 
O references 
public override void context) 
AS er•t. (context , "context " ) ; 
'kdialtem iygeltem — null; 
if (context. Items. Length I) 
imagelt& = context. 
else { 
Log. Item Returned - Image Compress" 
/ Target Path/ Target 
this); 
public string GetTargetPathWithFiIeNaæ(mediaItem image) 
String E?rgetpath = E.ty 
targetpath image _ path; 
int startlndex — targetpath. ? • 
int count — targetpath. Length • targetpath.IndexOf(•?'); 
targetpath = targetpath.Remve(startIndex, count); 
return targetpath;

Update the scale Factor with values to have different ratio of compression

Points to be Noted:

  • Once you have created a new Menu option in Core DB, under /sitecore/content/Applications/Content Editor/Context Menues/Default this Option will be displayed for all items in the Content tree.
  • But it doesn’t make any sense for every Sitecore item to have a compress option and it is not a best practice as well.
  • So that leads us to, Only the Image and it relevant items should only have this Compress option enabled.

This can be achieved by overriding the QueryState method. Here we handle the scenarios when we have to enable the Compress Option and when we have to hide it.

The Template IDs we refer here are Sitecore Image/Jpeg media item’s template. So this option will be shown only for images in Sitecore.

Images 
Favicons 
Guardian 
Authors 
Logo 
Sports 
Profile Pictu 
Push 
SnakeRiv 
wp3157$ 
u 
Edit 
'G Project 
System 
Extension Ther 
Base Themes 
Themes 
tent Editor 
Media Lib 
(3 
X 
Insert 
Search 
Compress 
Duplicate 
Delete 
Rename 
Copying 
Sorting 
Experience Editor 
Publish Item 
Console 
Scripts 
Refresh
Foundation 
Images 
to Favicons 
Guardian 
Authors 
Logo 
to Sports 
Profile Pictures 
Push 
SnakeRiver5mb 
wp3157988png 
Project 
System 
Quic 
Item 
Item 
Item 
Tern I 
Crea 
Compressed I 
Item

Sitecore – Task Schedulers

This is a 3 part post, where we will be creating a Sitecore Task Scheduler to read RSS Feed and create item in the sitecore item and finally, sort the created items using a custom Publish Date field.

Part 1 – Sitecore Task Scheduler

Sitecore has a build in Task Scheduling Agent that schedules predefined/build in tasks at the specified intervals.

Before discussing about more about this concepts or features I would like cite you how it can be put in to use.

Suppose you need a logic that needs to run at a specific time in a specific interval (Like a routine) like cleaning a database, posting contents to Web API or Sending a report  etc, Sitecore Task Scheduler are to the rescue.

Let’s look on how we can read a RSS Feed at a specific interval daily and create Items in Sitecore Content Tree and publish them using a Custom Task Scheduler which can then be presented in the website based on the UI.

For every Task Scheduler to be created an Run, we need three components.

  1. Command — This is the Logic(the code) that needs to be executed every time when the scheduler schedules the TASK
  2. Items – This is the item that will be passed as an Argument to the logic and our operations can be carried out in this item.(Item can be subjected to CRUD)
  3. Schedulers — This has the data on when a command needs to be called, at what time interval and has the data on when it’s Last Run.

All these components can be found under – /sitecore/system/Tasks — It is recommended to create Custom Tasks under this content so that it will be easy to manage.

Command: Create a custom command under /sitecore/system/Tasks/Commands/Your Project/Command using the system command template – /sitecore/templates/System/Tasks/Command

  • The created item will have two fields – Type and Method.
    • Type  – refers to your Namespace with Class Name and Assembly in should be provided in the format (MySitecore.Features.NewsFeed.Tasks.SyncRSSFeed,MySitecore.Features.NewsFeed)
    • Method – the method name in your class to which the control will be passed.

Scheduler: Create a Custom Scheduler Item under /sitecore/system/Tasks/Schedules/Your Project/Scheduler using the system Scheduler template – /sitecore/templates/System/Tasks/Schedule

  • The Schedule Item has the following key fields
    • Command – It’s of DropTree type with the Command Folder as it’s source. You can select the command item created from the DropDown
    • Items – Map the Item that needs to be passed to the custom logic
    • Schedule –  The Interval in which the task needs to be run it should be specified in the following format –

{start timestamp} | {end timestamp} | {days to run bit pattern} |{interval}

Start/End Timestamp Format – YYYYMMDD in this example it’s 20190816 and I don’t have an end date so I have set to the maximum – 99990101

  • The Day are set in bit pattern. With a bit value for each day of the week.
    • Sunday – 1
    • Monday – 2
    • Tuesday – 4
    • Wednesday – 8
    • Thursday – 16
    • Friday – 32
    • Saturday – 64
  • So if mention the sum of the days for which the tasks needs to be run for example, if it needs to be run every Monday set the value to 2. If it needs to be run every Monday and Tuesday (2+4) set the value to be 6
  • If it needs to be run everyday – sum of all the days – 127 would be the value. In this example I have set it to 127
  • Interval = HH:MM:SS 01:00:00 means the task will run every one hour. 00:02:00 means the task will run every 2 minutes.
  • Last run –  Indicates the value to last run date/time

Part – 2  Read RSS Feed and Create Items based on RSS Item template programmatically.

Now to the Custom Class (Mentioned in the Command Item – Type field). You can check creating the Sitecore command/schedule items and creating the class with Execute method and specifying it’s information to the created Sitecore item. To check simply put in a log and check the log file whether the log text is present.

We will work on the logic for reading the RSS Feed and creating Items in Sitecore based on the RSS Item Template. I have created a RSSItem in Sitecore with the following fields.

RSSItem

RSS Feed:

The idea is to have a Folder Item (RSS) that will be passed as an input to the Task Scheduler. This RSS Folder will have sub items of type RSS Feed. The RSS Feed  has two fields – Name and the Feed URL. Based on the feed URL, RSS Item will be created as a sub item under the corresponding RSS Feed.

In a nutshell, the final folder will be something  like

Now we will add logic to read RSS Feed and Create RSS Item in Sitecore whenever this Task is RUN.

Part – 3 Custom Sort – Based on the PubDate field

Sitecore generally sorts sub items based on the item name. It can also be sorted based on other parameters like Created, Updated, Reverse etc all these are OOTB.

After reading the Feed and creating the RSS Items under RSS Feed, the created items will be sorted by the RSS Item Name. While setting this as a data source to a rendering the latest RSS Item from the RSS Feed wont be displayed as sub items are sorted based on their title.

But while displaying the feed in our website, it would be useful only if the latest items are displayed first. In order to achieve this, we will creating a Custom Sort Approach based on the Published Date by extending the system comparer class.

To Create a custom sort, we need to create a class that extends Sitecore.Data.Comparers.ExtractedKeysComparer.

And we can add our logic by overriding the following three methods, DoCompare,ExtractKey and CompareKeys

DoCompare compares the items based on the field name and returns the sorted item list.

Extract Key Returns the key object (the item and the key-Published Date field value)

Based on the keys, the items will be compared in CompareKeys method.

Now create a Child Sorting Item named Publish Date under /sitecore/system/Settings/Subitems Sorting and update the Type – Class, Assembly

Now the created Child Item Sorting will be listed in the Sub Item sorting option.

Now this Item can be rendered based on your requirement in your website.

Design a site like this with WordPress.com
Get started