使用PowerShell腳本從Solr獲取數據並在Sitecore中進行編輯


1

有沒有一種方法,我可以查詢Solr 來基於模板獲取數據。然後 foreach 對該數據執行 Sitecore Getitem Update 一個字段的值。

1

I would first start with the following commands:

  • Find-Item : Use this to query the index
  • Initialize-Item : Use this to convert the data from the index into Sitecore items
  • The items that come back can then be managed directly like seen here

Example: The following example finds all items in the master index inheriting from the "Sample Item" template. Those items are retrieved and the title field is updated with the current date.

$criteria = @(
    @{Filter = "Equals"; Field = "_templatename"; Value = "Sample Item"; }
)
$props = @{
    Index = "sitecore_master_index"
    Criteria = $criteria
}

$items = Find-Item @props | Initialize-Item
foreach($item in $items) {
    $item.Title = "Current time: $(Get-Date)"
}