Ejemplo n.º 1
0
        private string GetAssociationMetaData(EntryContentBase currentContent)
        {
            // not good, find a better way than do this twice
            IEnumerable <EPiServer.Commerce.Catalog.Linking.Association> assoc = currentContent.GetAssociations();
            StringBuilder strB = new StringBuilder();

            if (assoc.Count() >= 1)
            {
                // Fix code and formatting, but it works
                EPiServer.Commerce.Catalog.Linking.Association a = assoc.FirstOrDefault(); // get the only one .. so far for test
                strB.Append("GroupName: " + a.Group.Name);
                strB.Append(" - ");
                strB.Append("GroupDescription: " + a.Group.Description); // doesn't show - investigate
                strB.Append(" - ");
                strB.Append("GroupSort: " + a.Group.SortOrder);
                strB.Append(" - ");
                strB.Append("TypeId: " + a.Type.Id); // where the filter could be applied
                strB.Append(" - ");
                strB.Append("TypeDescr: " + a.Type.Description);
                // there is more to get out
                ContentReference theRef = a.Target;
                strB.Append("...in TrousersController");
            }
            else
            {
                strB.Append("Nothing");
            }

            return(strB.ToString());
        }
Ejemplo n.º 2
0
        // ToDo: clean up here ... have an Aggergation for this part ... could use as demo
        private IEnumerable <ContentReference> GetAssociatedEntries(EntryContentBase currentContent)
        {
            // using linksRep is gone
            IAssociationRepository _linksRep = ServiceLocator.Current.GetInstance <IAssociationRepository>();

            IEnumerable <EPiServer.Commerce.Catalog.Linking.Association> linksRepAssoc =
                _linksRep.GetAssociations(currentContent.ContentLink).Where(l => l.Group.Name == "CrossSell");
            // would like to be able to filter when calling, instead of .Where()

            // would like to get the metadata out ... like type and group... and probaly treat them differently
            IEnumerable <EPiServer.Commerce.Catalog.Linking.Association> assoc = currentContent.GetAssociations();

            List <ContentReference> refs = new List <ContentReference>();

            foreach (EPiServer.Commerce.Catalog.Linking.Association item in assoc)
            {
                refs.Add(item.Target);
            }

            return(refs);
        }
        private Dictionary <string, ContentReference> GetAggregatedAssocciations(EntryContentBase currentContent)
        {
            // should return a chunk for each Assicciation
            IEnumerable <EPiServer.Commerce.Catalog.Linking.Association> assoc = currentContent.GetAssociations();
            Dictionary <string, ContentReference> localStuff = new Dictionary <string, ContentReference>();

            if (assoc.Count() > 0)
            {
                foreach (var item in assoc)
                {
                    localStuff.Add(GetAssociationMetaDataSingle(item), GetAssociatedEntry(item)); // need to refactor the returntypes and the
                    //localStuff.Add("Nothing", ContentReference.SelfReference); // just to some back... for now
                }
            }
            else
            {
                localStuff.Add("Nothing", ContentReference.SelfReference); // just to some back... for now
            }
            return(localStuff);

            // may need theese (supporting classes)
            //AssociationModel otherModel = new AssociationModel();
            //List<AssociationModel> otherModels = new List<AssociationModel>();
        }