private static IEnumerable <Item> GetMultiVariateTestDataSourceItems(this RenderingReference reference)
        {
            var list = new List <Item>();

            if (reference != null && !string.IsNullOrEmpty(reference.Settings.MultiVariateTest))
            {
                using (new SecurityDisabler())
                {
                    // Sitecore 7 to Sitecore 8:
                    //var mvVariateTestForLang = Sitecore.Analytics.Testing.TestingUtils.TestingUtil.MultiVariateTesting.GetVariableItem(reference);

                    // Sitecore 8.1 and above:
                    var contentTestStore     = new Sitecore.ContentTesting.Data.SitecoreContentTestStore();
                    var mvVariateTestForLang = contentTestStore.GetMultivariateTestVariable(reference, reference.Language);

                    var variableItem = (mvVariateTestForLang != null) ? mvVariateTestForLang.InnerItem : null;
                    if (variableItem == null)
                    {
                        return(list);
                    }
                    foreach (Item mvChild in variableItem.Children)
                    {
                        var mvDataSourceItem = mvChild.GetInternalLinkFieldItem("Datasource");
                        if (mvDataSourceItem != null)
                        {
                            list.Add(mvDataSourceItem);
                        }
                    }
                }
            }
            return(list);
        }
        private static IEnumerable <Item> GetMultiVariateTestDataSources(this RenderingReference reference)
        {
            var list = new List <Item>();

            if (reference != null && !string.IsNullOrEmpty(reference.Settings.MultiVariateTest))
            {
                using (new SecurityDisabler())
                {
                    var testStore = new Sitecore.ContentTesting.Data.SitecoreContentTestStore();
                    var tests     = testStore.GetMultivariateTestVariable(reference, reference.Language);

                    if (tests != null && tests.InnerItem != null)
                    {
                        foreach (Item child in tests.InnerItem.Children)
                        {
                            var datasource = child.GetInternalLinkFieldItem("Datasource");
                            if (datasource != null)
                            {
                                list.Add(datasource);
                            }
                        }
                    }
                }
            }
            return(list);
        }