If you don't want to install SPE
module like @Michael West suggested, there is another way to do this. You can implement a custom class for your agent and add it to schedule with a config patch.
A config patch to add your class to the schedule can look like this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<scheduling>
<agent type="YourNamespace.YourAgentClass, YourAssemblyName" method="Run" name="AgentName" interval="01:00:00"/>
</scheduling>
</sitecore>
</configuration>
In that config patch, you specify your agent's class name, a method to execute (Run
) and interval.
Your custom class can look like this:
public class YourAgentClass
{
public void Run()
{
}
}
Inside Run
method you can use search index to find your items:
using (var context = index.CreateSearchContext())
{
var results = context.GetQueryable<ArticleSearchResultItem>()
.Where(item => item.TemplateId == ArticleTemplateId
&& item.IsFeatured == true)
.ToList();
}
ArticleSearchResultItem
class can look like this:
public class ArticleSearchResultItem
{
[IndexField("_group")]
[TypeConverter(typeof(IndexFieldIDValueConverter))]
public virtual ID ItemID { get; set; }
[IndexField("_template")]
[TypeConverter(typeof(IndexFieldIDValueConverter))]
public virtual ID TemplateId { get; set; }
[IndexField("isfeatured")]
public virtual bool IsFeatured{ get; set; }
}
You can also extend existing SearchResultItem
class.