我们正在从7.0升级到Sitecore XP 8。我们用来获取“访问量最大的项目”的一段代码"从给定的起始路径使用Sitecore.Analytics.Data.DataAccess.DataAdapters命名空间以访问DataAdapterManager类。在Sitecore XP 8中,这已移至Sitecore.Analytics.Reporting.Data.DataAccess.DataAdapters命名空间,但现已过时。
以下是现在的代码:
/// <summary>
/// Get topCount most visited items, whose path starts with startPath
/// </summary>
/// <param name="topCount">Max number of items to retrieve</param>
/// <param name="startPath">Url path of the items</param>
/// <returns>Collection of top visited items</returns>
public static IEnumerable<Item> GetMostVisitedItems(int topCount, string startPath)
{
var sqlQuery = "select top " + topCount.ToString(CultureInfo.InvariantCulture) + " "
+ "{0}ItemId{1} "
+ "from {0}Pages{1} "
+ (string.IsNullOrWhiteSpace(startPath) ? "" : "where {0}Url{1} like '" + startPath + "%' ")
+ "group by {0}ItemId{1} "
+ "order by COUNT({0}PageId{1}) desc ";
var topPageItemIds = DataAdapterManager.Sql.ReadMany<Guid>(sqlQuery, reader => DataAdapterManager.Sql.GetGuid(0, reader));
return topPageItemIds.Select(itemId => Sitecore.Context.Database.GetItem(new ID(itemId))).Where(item => item != null);
}
是否有新的首选方式可以访问此相同的信息?
更新:除了Dmytro Shevchenko的精彩信息,我还在Accessing Current Visitor Information页面上的LaunchSitecore.net网站上找到了一些非常好的入门信息。这个特定的会话帮助当前访问者的数据,但它有助于指出用于分析的Sitecore类和命名空间。