Skip to content

Instantly share code, notes, and snippets.

@mskutta
mskutta / RegisterCustomCulture.cs
Created Nov 3, 2016
Sitecore Data Modeling Approach for Integrations
View RegisterCustomCulture.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View MostViewedHelper.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View ViewAggregationProcessor.config
<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 Jan 24, 2019
Sorting Sitecore Items by Popularity using xDB
View ViewAggregationProcessor.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View ViewPageEventProcessor.config
<?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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View ViewValue.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View ViewKey.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View ViewFact.cs
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 Aug 21, 2017
Sorting Sitecore Items by Popularity using xDB
View ViewPageEventProcessor.cs
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 Nov 2, 2016
Sorting Sitecore Items by Popularity using xDB
View Fact_Views.sql
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