Ecommerce Bug: CatalogManager.GetProduct(sku) throw NullRefe

Posted by Community Admin on 04-Aug-2018 13:18

Ecommerce Bug: CatalogManager.GetProduct(sku) throw NullReferenceException if SKU does not exist

All Replies

Posted by Community Admin on 29-Aug-2012 00:00

Calling the GetProduct method using an invalid product SKU throws a NullReferenceException rather than returning a null Product.

How to reproduce:

string badSKU = "0000-0000";
var catManager = CatalogManager.GetManager();
Product product = catManager.GetProduct(badSKU);

It's easy enough to work around using a try/catch block but if this is by design, it might be more appropriate to throw a more descriptive exception.

--Steve

This thread is closed