Monday, November 23, 2015

Sitecore options for serialization and deserialization

Serialization – Convert data/objects into stream of bytes.
Deserialization – Convert stream of bytes into data/objects

There are three options for serialization and deserialization in the Sitecore.

1)      The Sitecore serialization page provide the interface to transfer the database to the bytes/text files
Location is: - /Sitecore/admin/serialization.aspx
Helps to take backup of database, version control and to track the changes (in case of trouble shooting).

File created on the file system:- 


2)      Serializing Items through content editor option :-
Steps:-
To serialize an item:
1. In the Content Editor, select an item that you want to store in a text file on the disk.
2. On the Developer tab, in the Serialize group, click Serialize Item.

To show the developer options enable this from the ribbon bar:-



Click on serialize item:-


To serialize an item with all its sub items:
1. In the Content Editor, select a parent item that you want to store with all its sub items in text format on the disk.
2. On the Developer tab, in the Serialize group, click Serialize Tree.

3)      Sitecore event handlers :-
Need to enable the event handler by default it’s disabled

Add below configuration in the web.config file

             <configuration>
  <sitecore>
    <events>
      <event name="item:saved">
        <handler type="Sitecore.Data.Serialization.ItemHandler, Sitecore.Kernel" method="OnItemSaved"/>
      </event>
      <event name="item:deleted">
        <handler type="Sitecore.Data.Serialization.ItemHandler, Sitecore.Kernel" method="OnItemDeleted"/>
      </event>
      <event name="item:moved">
        <handler type="Sitecore.Data.Serialization.ItemHandler, Sitecore.Kernel" method="OnItemMoved"/>
      </event>
      <event name="item:versionRemoved">
        <handler type="Sitecore.Data.Serialization.ItemHandler, Sitecore.Kernel" method="OnItemVersionRemoved"/>
      </event>
    </events>
  </sitecore
</configuration> 





Other tools available on the Hedghog for the serialization and comparisons







No comments:

Post a Comment