Start a new topic
Answered

How to introduce new attribute to Item

Hello everybody.

First of all, I'm super new to Virto Commerce. 


I'm trying to introduce new attribute to Item. So I made these steps: 

  1. added new property 'Foo' in Item Entity + getter, setter
  2. generated new migration in VirtoCommerce.Foundation.Data.Catalogs and updated database
Now when I'm trying to add new Product in Virto Commerce manager I'm getting this error: 

An error occured while loading data form server:

System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request. ---> System.InvalidOperationException: The property 'Foo' does not exist on type 'VirtoCommerce.Foundation.Catalogs.Model.Sku'. Make sure to only use property names that are defined by the type. 


What am I missing? Where are property names defined? 

Thank you in advance.


 


Best Answer

You can simply add value to ItemPropertyValues object/table and those values will be accessible through API, but not editable in the admin or visible in frontend.


Answer

You can simply add value to ItemPropertyValues object/table and those values will be accessible through API, but not editable in the admin or visible in frontend.

You shouldn't be modifying core classes like Item. In order to add additional attribute/property for the item, simply open commerce manager and modify "property set" and add new property in there. This can be done by going to Catalog edit screen and then "property sets" tab.

Oh I see. I wasn't very clear in my question. I understand the way how to add new property to Item like color, size etc.


But I need something else. Being more specific, I'm implementing XML export of items to 'goods aggregator'. I wanted to add flag 'isExportable' (exactly like 'isActive' and 'isBuyable') defining whether item will be exported or not. Unlike color and size this attribute must not be visible to customers. I think it belongs right to the Item entity because every single item will have this flag set. I think of propertySets being something little different. That's why I directly tried to add this attribute to Item. 


So is your recommendation to add this flag as item property to every item, though? How can I hide item property from end users? Isn't there any simple way how to add it right in the Item entity? 


Thank you very much for your clarification.

Login or Signup to post a comment