I would like to get some related products, when publishing a product page. I've specified some product categories, so two product are related products if they have at least one common category.
I've tried the following:
- get product pages with same categories as the actual page to be published. I've the following code:
void PublishedContentHandler(object sender, ContentEventArgs e)
if (e.Content.GetType().Name == "ProductPageProxy")
var productpage = (ProductPage)e.Content;
var selectedItem = productpage.Category;
var cat = new CategoryHelper();
var pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, cat.SelectedCriteria(selectedItem.ToString()));
productpage.RelatedContentArea = new ContentArea();
foreach (var page in pages)
// at that moment I have in variable pages the productpages to add to relatedcontentarea, and it's ok, but from now on it's not working...no pages saved on relatedcontentarea of productpage I'm publishing
e.Content = productpage;
If you use SavingContent event then you could modify the content properties before they will be saved.
But you are using PublishedContent event - setting properties here without explicit saving content has no effect.
The GetForceCurrentVersionSaveAction() extension method is not responsible for saving content. It's just returns the proper SaveAction for content instance.
I think that you could try to use: