Views: 3224
Number of votes: 0
Average rating:

Get the PageData of some Catalog Node

Below function can help you to retrieve PageData object of some CatalogNode without effecting performance.


        private PageData FindPageByCatalogNode(CatalogNode catalogNode)
        {
            string text = (catalogNode.ParentNode != null) ? catalogNode.ParentNode.ID :
            CatalogContext.Current.GetCatalogNode(catalogNode.ParentNodeId).ID;
            if (text == null)
            {
                CatalogDto catalogDto = CatalogContext.Current.GetCatalogDto(catalogNode.CatalogId);
                text = ((catalogDto == null || catalogDto.Catalog == null || catalogDto.Catalog.Count == 0)
                ? string.Empty : catalogDto.Catalog[0].Name);
            }
            string key = MappedPPDB.BuildKey(new object[]
            {
                catalogNode.CatalogNodeId,
                string.Empty,
                catalogNode.ParentNodeId,
                catalogNode.CatalogId,
                NodeType.CatalogNode,
                catalogNode.ID,
                text
            });
            int id = MappedPPDB.Instance.LoadMapping("CatalogPageProvider", key).Id;
            return DataFactory.Instance.GetPage(new PageReference(id, "CatalogPageProvider"));
        }

Apr 11, 2013

Please login to comment.