我使用 Sitecore PowerShell 扩展模块创建脚本,将关系从一项复制到相关项。
我用来Get-ChildItem获取与特定字段相关的所有项目
Get-ChildItem -Recurse . | Where-Object {
$_.TemplateName -match $'myTemplate' -and
$_.Fields[$fromfield].Value -ne $null -and
$_.Fields[$fromfield].Value -ne ""
} | ForEach-Object {
}
Run Code Online (Sandbox Code Playgroud)
由于数据很大,我花了大约 1 分钟来获取所有项目。
所以我尝试使用Find-Item来使搜索过程更快
Find-Item -Index 'sitecore_mastre_index' -Where 'TemplateName = @0' -WhereValues 'myTemplate'
Run Code Online (Sandbox Code Playgroud)
它给了我以下警告,请注意我使用 Sitecore 版本 7.2
警告:由于平台限制,此版本的 Sitecore 不支持参数Where。
从 Sitecore 版本 7.5 开始支持此参数
有没有办法使用 PowerShell 比使用更快地检索数据Get-ChildItem?
注意:如果我使用 Get-Item .查询,则仅返回前 100 项。我还有很多物品。