Developer forum

Forum » Development » product.GetCategoryValue throws NullReference in 8.7

product.GetCategoryValue throws NullReference in 8.7

Kevin Steffer
Reply

Hi,

When I inside product list template extender or product template extender try to get product category values with fx

product.GetCategoryValue("<product category>", "<field name>");

it throws me a NullReference error of this kind:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.eCommerce.Products.Group._Closure$__277._Lambda$__1102(Group g, Field f)
   at Dynamicweb.eCommerce.Products.Group._Closure$__277._Lambda$__1103(Group g, Field f)
   at Dynamicweb.eCommerce.Products.Group.GetProductCategoryFieldDefaultValue(Group group, Field field, Nullable`1 currentValOnlyOrInheritedValOnly, String languageId, String defaultLanguageId)
   at Dynamicweb.eCommerce.Products.Product.GetDefaultCategoryValue(IEnumerable`1 groupsCol, String primaryGroupId, String categoryID, Field field, String languageId, String defaultLanguageId)
   at Dynamicweb.eCommerce.Products.Product.GetCategoryValue(Dictionary`2 categoryFieldValues, IEnumerable`1 groups, String primaryGroupId, String categoryID, Field field, String languageId, String defaultLanguageId, Object defaultVal)
   at Dynamicweb.eCommerce.Products.Product.GetCategoryValue(String categoryID, Field field, Object defaultVal)
   at Co3.Modules.Extenders.ProductListTemplateExtender1.ExtendTemplate(Template template) in c:\Data\Dev\git\Co3\co3-solution\Co3\Co3.Modules\Extenders\ProductListTemplateExtender1.cs:line 24
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProductListTemplateExtenders(ProductCollection ProductList, Template Template)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderProducts(ProductCollection Products, Template ParentTemplate, String LoopName, Int32 LoopCounter, Boolean renderRelatedProducts, Boolean renderRelatedLists)
   at Dynamicweb.eCommerce.Frontend.Renderer.internalRenderProducts(ProductCollection products, Boolean isProductsFromIndex)
   at Dynamicweb.eCommerce.Frontend.Frontend.ListProducts(ProductCollection products, String groupsIdent, Boolean hasBeenSorted)
   at Dynamicweb.eCommerce.Frontend.Frontend.List(String groups)
   at Dynamicweb.eCommerce.Frontend.Frontend.EcomRender()
   at Dynamicweb.eCommerce.Frontend.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.GetModule(DataRow& ParagraphRow)

It looks like it's because of the new Product Category default values on Groups, but is there a new way of getting the categoryvalue from a product?

Or is this a bug?


Replies

 
René Poulsen
René Poulsen
Reply

Hi Kevin,

Did you ever solve this?

 

You must be logged in to post in the forum