How can I access fields in my product catalog?

Posted by Community Admin on 05-Aug-2018 21:21

How can I access fields in my product catalog?

All Replies

Posted by Community Admin on 02-Sep-2011 00:00

I'm trying to do something like this:

private void setBannerDescription()
        
            String myPageName = "Mortgage";
            ProductsManager manager = ProductsManager.GetManager();
            Product currentItem = manager.GetProductItems()
                .Where(i => i.UrlName == myPageName)
                .FirstOrDefault();
            if (currentItem != null && currentItem.GetValue<string>("BannerDescription") != null)
            
                lblProdDesc.Text = currentItem.GetValue<string>("BannerDescription");
            
        

Is this anywhere close to how to work with products?  I couldn't find any documentation on this piece.  I've based this on my understanding of Lists.  Any help would be appreciated.  Thank you.

Posted by Community Admin on 07-Sep-2011 00:00

Hello Brad H,

This is exactly how you should do it with some small modifications:

String myPageName = "Mortgage";
ProductsManager manager = ProductsManager.GetManager();
ProductItem currentItem = manager.GetProducts()..Where(i => i.UrlName == myPageName).FirstOrDefault();
if (currentItem != null && currentItem.GetValue<string>("BannerDescription") != null)
    lblProdDesc.Text = currentItem.GetValue("BannerDescription");

I assume you use the Products sample from the 4.2 SDK.

Best wishes,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 07-Sep-2011 00:00

I was able to find the CatalogManager in the Ecommerce module namespace and that did the trick.

CatalogManager manager = CatalogManager.GetManager();
 Product currentItem = manager.GetProducts()
     .Where(i => i.UrlName == ProductName)
     .FirstOrDefault();
 if (currentItem != null && currentItem.GetValue<string>("BannerDescription") != null)
 
     lblProdDescription.Text = currentItem.GetValue<string>("BannerDescription");
 

Thanks.

This thread is closed