Skip to content

Instantly share code, notes, and snippets.

@mskutta
mskutta / RegisterCustomCulture.cs
Created November 3, 2016 15:23
Sitecore Data Modeling Approach for Integrations
string culture = "int";
string name = "Integration";
//Create Culture & Region Info with an existing Language Culture (Eg: en-GB)
CultureInfo cultureInfo = new CultureInfo("en-US");
RegionInfo regionInfo = new RegionInfo(cultureInfo.Name);
CultureAndRegionInfoBuilder cultureAndRegionInfoBuilder = new CultureAndRegionInfoBuilder(culture, CultureAndRegionModifiers.None);
cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(cultureInfo);
cultureAndRegionInfoBuilder.LoadDataFromRegionInfo(regionInfo);
cultureAndRegionInfoBuilder.CultureEnglishName = cultureAndRegionInfoBuilder.CultureNativeName = name;
@mskutta
mskutta / MostViewedHelper.cs
Created November 2, 2016 18:26
Sorting Sitecore Items by Popularity using xDB
public static List<Item> GetMostViewed(int count, int daysToInclude, List<Guid> templateIDs, List<Guid> mostViewedExcludeGuids)
{
var sqlServerDataApi = new SqlServerDataApi(Sitecore.Configuration.Settings.GetConnectionString("reporting"));
// Base Query
var query = @"SELECT TOP " + count.ToString() + @"
A.ItemId,
A.DailyCount,
A.LastViewDate
FROM
@mskutta
mskutta / ViewAggregationProcessor.config
Last active November 2, 2016 18:26
Sorting Sitecore Items by Popularity using xDB
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<group groupName="analytics.aggregation">
<pipelines>
<interactions>
<processor type="Website.Logic.Analytics.Views.ViewAggregationProcessor, Website" />
</interactions>
</pipelines>
</group>
@mskutta
mskutta / ViewAggregationProcessor.cs
Last active January 24, 2019 17:20
Sorting Sitecore Items by Popularity using xDB
using System;
using System.Linq;
using Sitecore.Analytics.Aggregation.Pipeline;
using Sitecore.Diagnostics;
namespace Website.Logic.Analytics.Views
{
public class ViewAggregationProcessor : AggregationProcessor
{
protected override void OnProcess(AggregationPipelineArgs args)
@mskutta
mskutta / ViewPageEventProcessor.config
Created November 2, 2016 17:30
Sorting Sitecore Items by Popularity using xDB
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<endAnalytics>
<processor type="Website.Logic.Analytics.Views.ViewPageEventProcessor, Website" patch:before="processor[@type='Sitecore.Analytics.Pipelines.EndAnalytics.SaveDuration, Sitecore.Analytics']"/>
</endAnalytics>
</pipelines>
</sitecore>
</configuration>
@mskutta
mskutta / ViewValue.cs
Created November 2, 2016 15:22
Sorting Sitecore Items by Popularity using xDB
using Sitecore.Analytics.Aggregation.Data.Model;
using System;
namespace Website.Logic.Analytics.Views
{
public class ViewValue : DictionaryValue
{
internal static ViewValue Reduce(ViewValue left, ViewValue right)
{
var viewValue = new ViewValue();
@mskutta
mskutta / ViewKey.cs
Created November 2, 2016 15:19
Sorting Sitecore Items by Popularity using xDB
using System;
using Sitecore.Analytics.Aggregation.Data.Model;
namespace Website.Logic.Analytics.Views
{
public class ViewKey : DictionaryKey
{
public Guid ItemId { get; set; }
public DateTime Date { get; set; }
}
@mskutta
mskutta / ViewFact.cs
Last active November 2, 2016 15:19
Sorting Sitecore Items by Popularity using xDB
using Sitecore.Analytics.Aggregation.Data.Model;
namespace Website.Logic.Analytics.Views
{
public class ViewFact : Fact<ViewKey, ViewValue>
{
public ViewFact() : base(ViewValue.Reduce)
{
}
@mskutta
mskutta / ViewPageEventProcessor.cs
Last active August 21, 2017 12:36
Sorting Sitecore Items by Popularity using xDB
using System;
using Sitecore.Analytics;
using Sitecore.Diagnostics;
using Sitecore.Pipelines;
using Website.Logic.Common.Extensions;
using Sitecore.Data;
using Newtonsoft.Json;
namespace Website.Logic.Analytics.Views
{
@mskutta
mskutta / Fact_Views.sql
Last active November 2, 2016 15:19
Sorting Sitecore Items by Popularity using xDB
ALTER TABLE [dbo].[Fact_Views] DROP CONSTRAINT [FK_Fact_Views_Items]
GO
/****** Object: Table [dbo].[Fact_Views] Script Date: 8/22/2016 8:44:14 AM ******/
DROP TABLE [dbo].[Fact_Views]
GO
/****** Object: Table [dbo].[Fact_Views] Script Date: 8/22/2016 8:44:14 AM ******/
SET ANSI_NULLS ON
GO