Entity extension in nop 4..3

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 Jahre weitere
Hi
I am trying to extend Category entity and add a new field in the category table. I created a new entity named Category inheriting existing Category entity in the plugin project. I added a new bool  property to it.

I created the necessary classes to implement my new functionality.
During fetching of records from service class to get all the categories using new entity and returning the new bool property from db, the CategoryRepository.Table query is throwing exception. The c.Delete is not a table.

Is there a better way to do this without disturbing the nop commerce code base?

Thanks
3 Jahre weitere
If you're adding 'a new field in the category table', it sounds like you are disturbing things anyway.
See docs Updating an existing entity. How to add a new property.

An alternate would be to use a GenericAttribute  (but unless you use a Plugin, you still would be "disturbing the nop commerce code base" ;)
3 Jahre weitere
Hi vrivonkar, the approach I decided to take was to add a new entity "side-by-side" with the existing entity using the Id of the nopCommerce entity as a foreign key in my extension entity.  This way I don't have to change too much of the nopCommerce code and my schema is separate.  Obviously when you need your extra properties you need to load your own entity as well, so it might not work for you.  In my case I only needed for background processing and I did not need to load it every time that the nopCommerce entity was loaded.  If you need to show your attributes on the page then you are probably going to have to add properties to the relevant UI Model.  UI Models are loaded through "model factories" so you will need to provide your own implementation which inherits from the nopCommerce version and overrides the appropriate method, then add code to populate the extra model properties you added.  If this all seems to much then GenericAttributes might be worth looking at :-)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.