protected internal IEnumerable <Attribute> GetNodeEntryRelations(string catalogName, ICatalogEntryRowMapper entryRow) { var nodeEntryRelations = from relationRow in entryRow.GetNodeEntryRelationRows().Where(r => r.CatalogId == entryRow.CatalogId) let node = _catalogSystem.GetCatalogNode(relationRow.CatalogNodeId) where node != null select new { Row = relationRow, Node = node }; var isInStock = entryRow.InventoryRow != null && entryRow.InventoryRow.InStockQuantity > 0; var loadedSortOrder = false; var allNodes = new HashSet <string>(); var allOutlines = new List <string>(); foreach (var nodeEntry in nodeEntryRelations) { if (!loadedSortOrder) { yield return(NewAttribute("_sortorder", isInStock ? nodeEntry.Row.SortOrder : 0)); loadedSortOrder = true; } List <string> outlines; HashSet <string> nodes; ExtractNodesAndOutlines(entryRow.CatalogId, catalogName, nodeEntry.Node, out outlines, out nodes); allNodes.UnionWith(nodes); allOutlines.AddRange(outlines); } yield return(NewAttribute("_node", allNodes)); yield return(NewAttribute("_outline", allOutlines)); }
public IEnumerable <string> Included(Promotion promotion) { var settings = (Apps_Marketing_Promotions_BuySKUFromCategoryXGetDiscountedShipping.Settings) new XmlSerializer(typeof(Apps_Marketing_Promotions_BuySKUFromCategoryXGetDiscountedShipping.Settings)).Deserialize(new MemoryStream(promotion.PromotionRow.Params)); if (settings == null) { return(Enumerable.Empty <string>()); } var nodeId = _catalogSystemMapper.GetCatalogNode(settings.CategoryCode).CatalogNodeId; var entryIds = _catalogSystemMapper.GetCatalogRelations(0, nodeId).Select(r => r.CatalogEntryId); return(entryIds.Select(ei => _catalogSystemMapper.GetCatalogEntry(ei)).Where(e => e != null).Select(e => e.Code)); }