Help with IndexProvider #7762
-
I need to create index for ContentItem once its saved from the admin UI. public class UserByPrinterIndexProvider : IndexProvider<ContentItem>
{
public override void Describe(DescribeContext<ContentItem> context)
{
context.For<UserByPrinterIndex>()
.Map(contentItem =>
{
var printer = contentItem.As<Printer>();
if (printer == null)
{
return null;
}
var results = new List<UserByPrinterIndex>();
//for each selected printer create index
foreach (string user in printer.Content.Printer.Users.UserNames)
{
results.Add(new UserByPrinterIndex
{
PrinterId = printer.PrinterId.Text,
PrinterContentItemId = contentItem.ContentItemId,
UserName = user,
});
}
return results;
});
}
} How cat i run it once content item created, updated, deleted? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Did you register it with dependency injection?
That should be all you need to do. |
Beta Was this translation helpful? Give feedback.
-
Did you create your index table through a |
Beta Was this translation helpful? Give feedback.
-
Did you register it ;)
|
Beta Was this translation helpful? Give feedback.
-
No luck ;) Need to leave soon, but can you share your full code so that someone will review it |
Beta Was this translation helpful? Give feedback.
No luck ;)
Need to leave soon, but can you share your full code so that someone will review it