Skip to content

Item object should have standard enriched properties no matter how it is retrieved #1395

@AdamNaj

Description

@AdamNaj

Because of the nature of PowerShell pipelines, the Sitecore fields mapped as properties or properties like PSProviderPath are only available if you get the items from the provider like through the Get-Item (or use Initialize-Item cmdlet), however if you will get the item through the standard Sitecore API, the item won't be enriched.

As far as I can tell, the fields cannot be populated because any property that is dynamic cannot be attached through the .ps1xml file or any pipeline mechanics, but at least we can assert that the following accelerator properties are always there:

Property Name Property value retrieval script
ProviderPath [Spe.Core.Utility.PathUtilities]::GetProviderPath($this)
BaseTemplate [Sitecore.Data.Managers.TemplateManager]::GetTemplate($this).GetBaseTemplates()
ItemPath $this.Paths.Path
FullPath $this.Paths.FullPath
MediaPath $this.Paths.MediaPath
ContentPath $this.Paths.ContentPath

Additionally all the "Standard Fields were moved to .ps1xml which results in the same effect of not having to attach them programmatically and them always being there, even if the item was retrieved from Sitecore API directly.

The following benchmark:

# Retrieve Unwrapped item 50k times using Sitecore API
Measure-Command -Expression {
1..50000 | % { $database = get-database master; $database.GetItem("/sitecore/content/home") }
} | fl TotalSeconds, TotalMilliseconds

# Retrieve Wrapped item 50k times with full dynamic properties
Measure-Command -Expression {
1..50000 | % { gi master:\content\home }
} | fl TotalSeconds, TotalMilliseconds

Effects in this results:

From API From Provider (wrapped)
Before 1392 15035
After 1466 10973

Which indicates that while the unwrapped (but still somewhat enriched) itrem from API is retrieved negligibly slower, the wrapping process is roughly 30% faster now.

On top of the different wrapping functionality, a specialized property accessor was added so it requires no script-properties.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions