How can I access fields in my product catalog?
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"
);
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"
);
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 >>
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"
);