2

Is there a way that i can Query Solr to get data based on a template. Then foreach of that data do a Sitecore Getitem and Update a field's value.

1

1 Answer 1

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)"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.