Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Issue with adding new property to Product/Variant

Vote:
 

We have recently successfully migrated our application to Commerce 14. I am not sure if issue is because of migration. I am trying to add a new Property to Product but it is not reflecting on Commerce Catalog UI for product. Below is the class GenericProduct/BaseProduct where I am trying to add new property

 

GenericProduct inheriting BaseProduct

 

BaseProduct Inheriting ProductContent

 

New Property:

 

[Searchable]
[CultureSpecific]
[Tokenize]
[IncludeInDefaultSearch]
[BackingType(typeof(PropertyString))]
[Display(Name = "Style Group", Order = 25)]
public virtual string StyleGroupName { get; set; }

 

Seems like new property is getting created in db as I tried to change backingtype and i got some error. As I am pretty new to Commerce I thought creating new property is same as we create in CMS. I guess db and UI is not getting sync. Do we need to add any setting or code for any synchronization in Commerce?

#334552
Edited, Dec 19, 2024 12:04
Vote:
 

No that should just work. You don't need this attribute [BackingType(typeof(PropertyString))] however as string is a supported out of the box type ...

#334787
Dec 25, 2024 17:18
Vote:
 

But I am getting below error

System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.Reference.Commerce.Site.Features.Product.Models.GenericProduct_DynamicProxy.get_StyleGroupName()
   at lambda_method629(Closure , Object , Object[] )
   at EPiServer.Validation.DataAnnotationsValidator`1.ValidateInstance(Object instance, List`1 validationResult, ValidationContext validationContext)
   at EPiServer.Validation.DataAnnotationsValidator`1.Validate(T instance)
   at EPiServer.Validation.Internal.ContextValidatorWrapper`2.Validate(Object instance)
   at EPiServer.Validation.Internal.ValidationService.ValidateRecursively(Object instance, Object context, HashSet`1 visitedInstances)
   at EPiServer.Validation.Internal.ValidationService.Validate(Object instance)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at EPiServer.Cms.Shell.UI.Rest.Internal.ContentDataStore.<>c__DisplayClass20_0.<Validate>b__0(IContent content)
   at EPiServer.Cms.Shell.UI.Rest.Internal.RestStatusUtil.ExecuteWithSecurityCheck[T](ContentReference contentLink, IContentLoader contentLoader, AccessLevel accessLevel, Func`2 func)
   at EPiServer.Cms.Shell.UI.Rest.Internal.ContentDataStore.Validate(ContentReference id, ValidationFilering filter)
   at lambda_method575(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Accept: application/javascript, application/json
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9
Connection: close
Content-Length: 33
Content-Type: application/json
Cookie: AcceptedCookies=1; EPiServer_Commerce_AnonymousId=3dbcfae5-7e8c-4e46-954d-d54854b504ba; Language=en; MarketId=EU; CompareMessage=; CompareList=SPOKAL20-001; EPiStateMarker=true; .AspNetCore.Cookies=chunks-2; .AspNetCore.CookiesC1=CfDJ8M6iC_O6WlFHgmGGs_DM9wYtFKMQPJSl77OJRYndY4S4dYXZ7xK3tqS6LmHARWbLmS6eviFUdAN0DUYzzleKanvuDoK1uVjQ3wlYAnyCfSMBSio3W3rferqdAB1WeL_x7gkCJxwGbpQO9F0Hc9zI5wkV81wrL9PBPRMD8pUQPPhBkHKl7BFvzrQrUGiUopB0CMTt8jVCjf8_LKBLCRT0tDxD_qV6u4G2lwS8cGR7mN1YAUo07GtQzdReYr-f-0ObSMQhNQIa0iPDx-V1ca1IHa-a02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=CfDJ8M6iC%2FO6WlFHgmGGs%2FDM9wYcfWHEASRWL8sp9%2FNo8V8aICx0hCbGI02BuJ6h4Eyd%2FmtkjcSVZLMTG%2FdcrHUhXbqio%2BbrK5GhxRiU1V3VoodH5WkD1DHmvhotd%2BQr6EdbyaDrMR7HDI8tb9A69USoJOWFSKYRFh2Rm6d6iDH6haJU; .AspNetCore.Antiforgery.pCXWeLmJTSY=CfDJ8M6iC_O6WlFHgmGGs_DM9wbfCyW96j2WoktsvCeUee9LTTg61GpclKXzbX2o-WGpyB4Cxa0pBKUs69-o1FmDJ3gmd0NkZnvA8rulglZ-M1OsTQLsGaP6ojn42huNnKLGr9c6SWhAzd7mTFL_SC3upg0
Host: localhost:44323
Referer: https://localhost:44323/EPiServer/Commerce/catalog?menu=pages
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
requestverificationtoken: CfDJ8M6iC_O6WlFHgmGGs_DM9wYS2VuIMSuSko6hfIW5IEKLFwucEFwoVKUveeB2SEA8o6z_GJ_eu_r4vbfQsInTd4lU4voJqHvVRn-yr2tmCQagkk31UgVWTokVZx5r67HMhw5vDNsiccjd688Gie1tb5lyHMRJuxAzJgQNEfN79Kj_wqfrKnBQ9zCeflWMKGIVjQ
sec-ch-ua-platform: "Windows"
sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"
x-http-method-override: Validate
sec-ch-ua-mobile: ?0
x-requested-with: XMLHttpRequest
x-epicontentlanguage: en
x-epicurrentcontentcontext: 109147_140730620_CatalogContent
origin: https://localhost:44323
sec-fetch-site: same-origin
sec-fetch-mode: cors
sec-fetch-dest: empty
priority: u=1, i

#334974
Dec 30, 2024 16:26
Vote:
 

I tried adding property to CMS pagetype as well but there as well properties are not showing up in CMS edit mode. Tried with String,Int and bool property, in case of string property getting null reference exception but for other 2(int & bool) not even getting any error. However when tried creating property from Admin section through UI property is getting created. That means properties creating through code is not working.

 

#335010
Dec 31, 2024 10:55
Vote:
 

If you add another property without any attribute, just 

public virtual int SomeProperty {get;set;}

would it appear in the UI view?

#335011
Dec 31, 2024 13:47
iliyas shaikh - Jan 02, 2025 11:30
No. Not showing up on UI. But in case of String it is throwing Null reference Exception Object reference Not set to an instance of an object with source as "DynamicContentModelsAssembly"
Vote:
 

Found the solution. Got help from Huy Le of Optimizely. Issue was with ModelType of table "tblContentType". Set null to ModelType and run application once will fix the issue.

#335095
Jan 02, 2025 13:20
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.