protected void WalkCategoryTree(NodeContent node, IContentRepository repository, CatalogContentLoader contentLoader, ICatalogSystem catalog, ReferenceConverter referenceConverter) { // ReSharper disable PossibleMultipleEnumeration // Get all products Stopwatch tmr = Stopwatch.StartNew(); IEnumerable <EntryContentBase> entries = repository.GetChildren <EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase>(node.ContentLink); _log.Debug("Loaded {0} entries in category {1} using IContentRepository in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Load and cache Entry objects. Still a lot of code that uses this tmr = Stopwatch.StartNew(); foreach (EntryContentBase entryAsContent in entries) { // Load full entry int entryId = referenceConverter.GetObjectId(entryAsContent.ContentLink); // Catalog Gadget uses info //catalog.GetCatalogEntry(entryId, // new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)); catalog.GetCatalogEntry(entryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); } // Prime the catalog gadget // IEnumerable<IContent> children = repository.GetChildren<IContent>(node.ContentLink, new LanguageSelector("en"), 0, int.MaxValue); // _log.Debug("Loaded {0} children", children.Count()); // .GetDescendents(node.ContentLink); tmr.Stop(); _log.Debug("Loaded {0} entries in category {1} using ICatalogSystem in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Get all products the way it is done in edit mode, but this does not seem to // use the cache. //int loadedEntries; //contentLoader.GetCatalogEntries(node.ContentLink, 0, int.MaxValue, out loadedEntries); //_log.Debug("Loaded {0} entries in category {1} using CatalogContentLoader", loadedEntries, node.Name); // Get child nodes the same way done by the UI IList <CatalogGetChildrenReferenceResult> catalogNodes = contentLoader.GetCatalogNodes(node.ContentLink); _log.Debug("Loaded {0} categories in category {1} using CatalogContentLoader", catalogNodes.Count, node.Name); foreach (GetChildrenReferenceResult catalogNode in catalogNodes) { NodeContent childNode = repository.Get <NodeContent>(catalogNode.ContentLink); WalkCategoryTree(childNode, repository, contentLoader, catalog, referenceConverter); } // ReSharper restore PossibleMultipleEnumeration }
public void AddLineItem() { var entry = _catalogSystem.GetCatalogEntry(Constants.VariationCode); _helper.AddEntry(entry); var lineItem = _helper.LineItems.First(); lineItem.IsInventoryAllocated = true; lineItem.Quantity = 1; lineItem["Custom"] = true; _helper.Cart.AcceptChanges(); }
/// <summary> /// Gets the catalog entry. /// </summary> /// <param name="catalogEntryId">The catalog entry id.</param> /// <returns></returns> public Entry GetCatalogEntry(int catalogEntryId) { return(_Proxy.GetCatalogEntry(catalogEntryId)); }
protected void WalkCategoryTree(NodeContent node, IContentRepository repository, CatalogContentLoader contentLoader, ICatalogSystem catalog, ReferenceConverter referenceConverter) { // ReSharper disable PossibleMultipleEnumeration // Get all products Stopwatch tmr = Stopwatch.StartNew(); IEnumerable<EntryContentBase> entries = repository.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase>(node.ContentLink); _log.Debug("Loaded {0} entries in category {1} using IContentRepository in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Load and cache Entry objects. Still a lot of code that uses this tmr = Stopwatch.StartNew(); foreach (EntryContentBase entryAsContent in entries) { // Load full entry int entryId = referenceConverter.GetObjectId(entryAsContent.ContentLink); // Catalog Gadget uses info //catalog.GetCatalogEntry(entryId, // new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo)); catalog.GetCatalogEntry(entryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); } // Prime the catalog gadget // IEnumerable<IContent> children = repository.GetChildren<IContent>(node.ContentLink, new LanguageSelector("en"), 0, int.MaxValue); // _log.Debug("Loaded {0} children", children.Count()); // .GetDescendents(node.ContentLink); tmr.Stop(); _log.Debug("Loaded {0} entries in category {1} using ICatalogSystem in {2}ms", entries.Count(), node.Name, tmr.ElapsedMilliseconds); // Get all products the way it is done in edit mode, but this does not seem to // use the cache. //int loadedEntries; //contentLoader.GetCatalogEntries(node.ContentLink, 0, int.MaxValue, out loadedEntries); //_log.Debug("Loaded {0} entries in category {1} using CatalogContentLoader", loadedEntries, node.Name); // Get child nodes the same way done by the UI IList<GetChildrenReferenceResult> catalogNodes = contentLoader.GetCatalogNodes(node.ContentLink); _log.Debug("Loaded {0} categories in category {1} using CatalogContentLoader", catalogNodes.Count, node.Name); foreach (GetChildrenReferenceResult catalogNode in catalogNodes) { NodeContent childNode = repository.Get<NodeContent>(catalogNode.ContentLink); WalkCategoryTree(childNode, repository, contentLoader, catalog, referenceConverter); } // ReSharper restore PossibleMultipleEnumeration }