Sunday, November 27, 2022
Mesin Pelet Kayu Indonesia

How to Setup Sitecore 10 Content Serialization

– Advertisemen…

By Fathur , in Uncategorized , at 2022-10-31 标签:, , ,


– Advertisement –

Sitecore Content Serialization (SCS) is a system for serializing, sharing, and deploying content items, as well as keeping them in version control.


SCS is designed to help teams of developers that work on the same Sitecore solution to synchronize database changes between their individual development environments.

Sitecore Content Serialization comets with JSON based configurations in which we have certain options to configure while including and excluding the items.

Modes to Serialize

Combining the best of TDS and Unicorn, SCS give us the flexibility to move the content between environments. For this, we have two different tools mentioned below

  1. Sitecore CLI – A command line tool to interact with your Sitecore Instance.
  2. Sitecore for Visual Studio – A graphical tool to interact with Sitecore using Visual Studio.
https://www.altudo.co/-/media/altudo/images/resources/blogs/sitecore-10-content-serialization/10pic1.ashx?la=en&hash=3CBAEDD15AA265F40211FE8B7881874D

Structural Overview 


Serialize content items in and out of a Sitecore instance using Sitecore Content Serialization (SCS) system. We need to configure which content items to include and which ones to exclude, and which operation to perform on the content items.

The SCS system serializes content items into your project folder as YAML files. The default path is \serialization relative to module files, but we can configure any path we want.

Project Configuration file

The project configuration file is name sitecore.json. It has several properties including a modules property, serialization property.

{

  “$schema”: “./.sitecore/schemas/RootConfigurationFile.schema.json”,    

  “modules”: [ “src/*/*.module.json” ],

  “variables”: {},

    “serialization”: {

      “defaultMaxRelativeItemPathLength”: 120,

      “defaultModuleRelativeSerializationPath”: “serialization”

   }

}

Manual and automatic Serialization 

We can use manual serialization when we want to push or pull content items to or from a Sitecore instance on demand.

We can use automatic serialization to specify content items that you would like to have automatically serialized from a Sitecore instance to our file system when they are created and updated.

Including and excluding content Items

We single out subsets of content items for serialization with includes and rules. This is useful for repeating serialization of particular parts of your content item tree.

We configure what and how content items are included and excluded from serialization in a module file such as Project.module.json

“items”: {

  “includes”: [

    {

      “name”: “content”,

      “path”: “/sitecore/content/home”

    }

  ]

}

Rules

Rules are used to configure the serialization of content item tree. We configure rules with a path relative to the root path, the scope of content items to influence, and any alterations to the allowed push operations.

Example:

“items”: {

  “includes”: [

    {

      “name”: “content”,

      “path”: “/sitecore/content/home”,

      “rules”: [

        {

           “path”: “/products/legacy”,

           “scope”: “ignored”

        },

        {

           “path”: “/products”,

           “scope”: “ItemAndDescendants”,

           “allowedPushOperations”: “createUpdateAndDelete”

        },

        {

           “path”: “*”,

           “scope”: “ignored”

        }

      ]

    }

  ]

}

The rule system works by the first-match-wins principle, meaning that when a content item matches a rule, all subsequent rules are ignored:

  • The first rule tells SCS to ignore all content items in the /sitecore/content/home/products/legacy path.
  • The second rule tells SCS to serialize all content items in the /sitecore/content/home/products path. All subcontent items are included because the scope is ItemAndDescendants.
  • The third rule prevents SCS from serializing anymore /sitecore/content/home content items. The wildcard path of this rule matches all content items not matched by the previous rules, and the ignored scope prevents them from being serialized.

Sitecore Content Serialization Setup

With Sitecore 10 release, lot of new feature available like Containers, ASP.NET Core Rendering, Serialization and etc.

Prerequisites:

  • Visual Studio 2017/2019
  • Sitecore 10 instance
  • Sitecore CLI
  • .NET Core 3.1

Install Sitecore CLI (Command line interface)

Before installing CLI, make sure you have installed 3.1 version of .NET Core because the “dotnet new-tool manifest” command is available only in .Net Core 3+ version.

Setup Visual Studio Solution

Create a new project in Visual Studio and make sure you follow the Helix Architecture and go to the project folder.

Conclusion

As stated above, the Sitecore Serialization installation and configuration process is very straightforward, and it doesn’t have to be a “pull/push everything at once” solution, as it may seem. You can make the changes much more targeted by specifying tags in your modules’ configuration files. If you feel this setup little tough to do it yourself, you can hire Sitecore consulting and support services to complete Sitecore Serialization installation and configuration setup.

– Advertisement –

Comments