Sitecore Deletion of items

Abhishek Malaviya
2 min readMay 16, 2019

--

Here we are going to discuss many scenarios case by case, which may helpful for you:

1. Bulk deletion of items

We need to consider performance, following are the fastest options:

a). Sitecore Powsershell Extension(SPE)

This is very simple and easy way. Delete the items in a BulkUpdateContext - this disables events etc. So makes the delete run a lot faster. below is example:

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
Get-Item -Path master:/sitecore/Content/myItem | Remove-Item
}

Because this does disable events etc. you will probably need to re-index and run a smart publish once the items are deleted.

If don’t want to store deleted items into Recycle Bin then use Permanently parameter. Below is sample example:

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
Get-Item "master:/content/Something" | Remove-Item -Recurse -Permanently
}

If we passing Permanently - Specifies the item should be deleted rather than recycled.

Please go through link https://doc.sitecorepowershell.com/working-with-items.html for more details .

b). Classic old Sitecore approach

If don’t have Serialize tool set. Go to MY TOOLBAR -> Customize and add it.

Serialize the single root item and then clicking Revert Tree on that item. All the descendants were gone and you have to remove only the last item manually. It worked in EventDisabler mode and it was much much faster than deleting items manually.

All the other things like updating links database or index updates are not executed in this case, so it is very quick and optimize approach.

2. Permanently deletion at application level

By default if we delete item, it stores into Recycle Bin. This is desire and essential behavior. But if we don’t want to store any items to Recycle Bin.

Change config setting so once item deleted, don’t store into Recycle Bin. There is RecycleBinActive setting. Set value to false.

Create a patch file Disabled.Recycle.Bin.config and add it to App_Config/Include folder:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="RecycleBinActive">
<patch:attribute name="value">false</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>

Thanks for reading :)

--

--

No responses yet