+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / How can I access fields in my product catalog?

How can I access fields in my product catalog?

3 posts, 0 answered
  1. Brad H
    Brad H avatar
    9 posts
    Registered:
    20 Aug 2009
    02 Sep 2011
    Link to this post
    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.
  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    07 Sep 2011
    Link to this post
    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 >>

  3. Brad H
    Brad H avatar
    9 posts
    Registered:
    20 Aug 2009
    07 Sep 2011
    Link to this post
    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.
3 posts, 0 answered