Thursday, September 29, 2022

Sitecore upgrade from 8.2 to 10.2

Sitecore 10.2 installation and upgrade guide is available in the following path,

https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/102/Sitecore_Experience_Platform_102.aspx


Steps to follow for upgrade Sitecore 8.2 to 10.2:

1. Create the Sitecore packages from Sitecore 8.2 web applications. Create the separate packages for Templates, Media, Renderings. Dictionary and Content.

2. Install Sitecore 10.2 fresh instance and make sure the features are running perfectly fine.

3. Take a back up of Master DB, Core DB and website folder of Sitecore 10.2 instance.

4. Install the Sitecore packages on the new Sitecore instance.

5. Take the backup of Visual Studio solution(All projects) for Sitecore 8.2

6. Remove the references (physical files or NuGet packages) of Sitecore.Kernel, Sitecore.Mvc and any other dlls are being used.

7. Change the target framework of the Project from 4.6.2 to 4.8.

8. Add the Sitecore.Kernel, Sitecore.Mvc and any other references using NuGet Packages required for Sitecore 10.2 version.

9. Clean up the deprecated methods from the code and apply the code fixes if required.

9. Build the Solution.

10. Publish it on the new instance website folder.


Changes in Core DB:

1. Custom config file created but not a part of Visual Studio solution.

2. Changes done directly in the default config files.

3. Custom Core created in Search.

4. Third party integrations.

5. Any endpoint stored in Sitecore needs to be updated manually.


Thursday, September 15, 2022

View Types in Sitecore JSS ASP.NET core

 In MVC, the view is the most important layer used to represent the application's data, including user interactions. The Sitecore Rendering Engine renders Sitecore content using ASP.NET view components and partial views. These view types are used to create components within an ASP.NET Core application with the Sitecore Rendering Host. The three view types are model-bound views, custom view components, and partial views.

Model Bound Views :

The first view type to explore is a model-bound view. Model-bound views are backed by a default Sitecore view component which binds component content to a provided type. Model-bound views use the default SitecoreComponentViewComponent, so you do not need to create a view component class. When you have created both your Razor view in the /Views/Shared/Components/SitecoreComponent folder and your view model class, you must map the Layout Service response to the view component with the AddModelBoundView<TModel>() extension method (see Figure).



Custom View Components:

The second view type to explore is a custom view component. Custom view components (see Figure 2) are intended for use anywhere you have reusable rendering logic that is too complex for a model-bound view. 

Typically, view components do not use ASP.NET model binding and only access data on demand. However, the ASP.NET Rendering SDK provides a service and base component to enable binding a model to Layout Service output.

A view component consists of three files:

The view component class 

The Razor view

The view model class



Partial Views:

The third view type is a partial view. A partial view renders HTML output within another view's rendered output. Creating partial views in a Sitecore rendering host application follows the standard MVC conventions. Similarly, partial view discovery in a Sitecore rendering host follows the standard rules in ASP.NET Core MVC. You must map the Layout Service response to the partial view. These mappings are configured in the ConfigureServices() method in the Startup class (see Figure).




Tuesday, September 13, 2022

Sitecore Headless Development with ASP.NET and Sitecore containers

Sitecore Headless Development with ASP.NET and Sitecore containers with the launch of Sitecore 10 

Step 1: Download and Install

Using PowerShell, download and install the template within your file system using the following command:

dotnet new -i Sitecore.DevEx.Templates --nuget-source https://sitecore.myget.org/F/sc-packages/api/v3/index.json 


Step 2: Check for Existing Processes

Check for existing services on ports 443 and 8984. If there are running services on these ports, you will need to stop them. Note that you may run into port collision errors if you have other Sitecore environments running on your workstation. 

Examples of Stop commands:

iisreset /stop

Stop-Service -Name "<name of service>"

nssm stop "<name of service>" 


Step 3: Create the MyProject Solution

Change the directory of PowerShell to the location where you want to create and run your project. Then, create the MyProject solution with the command shown below.

dotnet new sitecore.aspnet.gettingstarted -n MyProject 


Note: This command will give you an option to run the dotnet tool restore command and if you choose to do so enter "y" to run the command.


Step 4: Prepare and Run the Initialization Script

Change the PowerShell directory to point to the newly created MyProject folder. This folder contains all the scripts and items necessary for the Getting Started project solution. The initialization script prepares a valid and trusted wildcard certificate for *.myproject.localhost, the host file entries for myproject.localhost, and the required environment variable values in the .env file for the Sitecore instance. 

To run this script, use the path to your valid Sitecore license and your administrative password. Run the initialization script with the command below. Make sure to click "Yes" after running the command for installing the certificate.

.\init.ps1 -InitEnv -LicenseXmlPath "<C:\...\license.xml>" -AdminPassword "<admin password>"


Step 5: Run the up.ps1 Script

Run the up.ps1 script to start up the environment with the command:

.\up.ps1


Step 6: Confirm the Environment is Running

Near the end of the startup process, a browser will open for you to log in to the Identity server. Use the administrative password entered in Step 4 to log in as the Administrator (user name: admin). The Identity server will then ask you to confirm device authentication. Once this is finished, the script will use the Sitecore Content Serialization CLI to deserialize the sample content items. 

At the end of the startup process, the script will open new browser tabs with both myproject.localhost (the Rendering Host) and cm.myproject.localhost (the Content Management, Content Delivery, and Sitecore Layout Service). From here, you can confirm the environment is running appropriately.

Wednesday, September 7, 2022

Sitecore JSS Setup - Steps

 

Sharing the Sitecore JSS setup steps that we usually follow in the project :

Sitecore Version - 10.x 

1.       JSS Setup on CM and CD server

a.       Install the JSS package on CM server by downloading it from Sitecore site.

b.       Once installed, generate the JSS API Key and publish it.

c.       Test the JSS URL on CM server. https://jss.sitecore.com/docs/client-frameworks/getting-started/jss-server-install

d.       Install the JSS manually on CD server. Kudu access is required for this. https://jss.sitecore.com/docs/client-frameworks/getting-started/jss-server-install

e.       Same API key should work on both CD and CM servers now.

2.       Deploying the code manually on CM and CD server:

a.       First publish the Sitecore web solution on both CM and CD servers. This will publish the config file overrides that are present in solution.

b.       Build the UI solution. It will copy the output to React-JSS solution.

c.       Build the React-JSS solution. It will copy the output to Node-Proxy solution.

d.       Copy the Sitecore/config files manually to both CM and CD servers

e.       Deploy the app with jss deploy items command for English. Section 3.2 - https://jss.sitecore.com/docs/client-frameworks/getting-started/app-deployment

f.        Create the ES language in Sitecore

g.       Repeat step e for Spanish language

h.       Copy the dist folder manually to both CM and CD

 

Errors:

1.       Speak-Layout.cshtml error. Fix is to change role in web.config to “ContentManagement” from “ContentManagement, Indexing” – Need to be done on every environment

2.       JSS Development workflow needs to be changed on every environment - https://jss.sitecore.com/docs/fundamentals/dev-workflows/code-first

3.       CD server throwing error for master db. Remove the DB name for CD server in JSS config file. – This needs to be done on every environment

4.       Font files giving 404. Needed to add mimetype in web.config – Needs to be done on every environment

 

Manual changes on every environment:

·       web.config - Add mimetype for otf fonts in – Both CM and CD

·       web.config – change role from  “ContentManagement, Indexing” to “ContentManagement”

·       JSS Development workflow, mark tasks as final

·       Remove the master db reference from JSS config on CD server only

·       Remove the / from solr URL in connection string file

·       Correct the domain names in connection string file

·       Owin.authentication.identityserver.config change Sitecore identity URL

 

How to Create a Public Link Using the Sitecore Content Hub REST API

Creating a public link using the Sitecore Content Hub REST API is a straightforward process that enables you to share content externally whi...