Duplicating an item using Duplicate Item command a new item is created. This new item contains the same number of versions and language variants as the original item. This is not optimal from the performance perspective. When number of records in the master database grows, the system requirements grow as well, and more records mean slower queries.
The next side effect is that DisplayName is also duplicated. And when an author sees two items with the same display name in the content tree he could get confused or make an error. He could easily mistake the original with the duplicate item.

Duplicate Item Advanced

That is why we’ve created our own duplication, which offers possibility to duplicate just the scope that author wants. He can choose from three different commands:

  • Duplicate All Language Versions
  • Duplicate Current Language Version
  • Duplicate Last Language Version
Context menu

Context menu

All three commands use the same processor they just set different type of operation in the pipeline arguments. The processor then executes the appropriate action base on the operation type set.

CustomItemDuplicate class

CustomItemDuplicate class

The method Execute reads pipeline arguments for information about the item being duplicated and type of duplication. It is stored in the class member field LatestVersionType.

advanced_duplicate_Code_snipet_CustomItemDuplicate_Execute

The method DuplicateItem cleans up the duplicated versions based on the member field LatestVersionType.

advanced_duplicate_Code snipet_CustomItemDuplicate_DuplicateItem

The methods „RemoveDisplayNameInAllLangs“ a „ClearDisplayNameField“ then clear duplicated DisplayName.

advanced_duplicate_Code snipet_CustomItemDuplicate_RemoveDisplayNameInAllLangs

advanced_duplicate_Code snipet_CustomItemDuplicate_ClearDisplayNameField

The commands must be add to sitecore configuration as well as the processor providing advanced duplication.

advanced_duplicate_commands_in_config

advanced_duplicate_IU_duplicate_in_config

The last step is to create new items in the context menu. Three items were created under the item /sitecore/content/Applications/Content Editor/Context Menues/Default and do not forget to set the correct command name in the Message field.

advanced_duplicate_context_menu_in_SC advanced_duplicate_context_menu_in_SC_2 advanced_duplicate_context_menu_in_SC_3