How can I remove duplicated page events in Sitecore 8.1?

醉酒当歌 提交于 2019-12-23 20:26:57

问题


I have a processor in the <registerPageEvent> pipeline that checks whether an event is duplicated and removes it. It works well on 7.2, but I have to upgrade to 8.1 Update 3 and I can't find a way to remove an already added page event. Is this possible and how can I do that?

Piece of code from 7.2:

Tracker.Visitor.DataSet.PageEvents.Rows.RemoveAt(Tracker.Visitor.DataSet.PageEvents.Count - 1);

回答1:


You cannot remove events via the API starting from Sitecore 7.5. (The only way around would be to use .NET reflection)

Even in 7.2, doing this was a bad idea. The reason being, when an event is added via the API, some internal logic is applied - e.g. the visit's total value is recalculated. If you remove an event manually, these internal actions will not be triggered, and hence, your visit data may end up in an inconsistent state.

The best approach for you would be to add checks in the code that registers your events - an event should only be registered if it's not a duplicate of an existing event.



来源:https://stackoverflow.com/questions/38762835/how-can-i-remove-duplicated-page-events-in-sitecore-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!