I want to extend the CatalogProduct model with my own model. I followed the CartModule example on GitHub. I think I did all the parts that the example had, but I still couldn't get it working.
Here are the items that I did:
- Installed the VirtoCommerce.CatalogModule.Data from NuGet to the module that I created.
- Created a MyProduct class, which inherit the CatalogProduct class.
- Created MyProductEntity class, which inherit the ItemEntity, and I override the ToModel, FromModel, and Patch functions.
- Created MyProductRepositoty class, which inherits the CatalogRepositoryImpl, and override the OnModelCreating function to tell which table I want to map to.
Modified the Module.cs file, and implemented the SetupDatabase(), Initialize(), and PostInitialize().
Here is what I put in for Initialize()
_container.RegisterType<ICatalogRepository>(new InjectionFactory(c => new MyProductRepository(_connectionStringName, _container.Resolve<AuditableInterceptor>(), new EntityPrimaryKeyGeneratorInterceptor())));
Here is what I put in for PostInitialize()
AbstractTypeFactory<CatalogProduct>.OverrideType<CatalogProduct, MyProduct>(); AbstractTypeFactory<ItemEntity>.OverrideType<ItemEntity, MyProductEntity>();
Rebuilt my module, and restarted the IIS
- I hit the localhost/admin/docs/VirtoCommerce.Catalog/v1 to see if the fields that I add to my model return from the Product definitions. It didn't.
Are there some steps I am missing? I actually got the migration working. It actually created the "MyProduct" table in the database.
Another question is that is it a good idea to add columns to the existing "Item" table? or is it advised to create a new table when extending the domain model?
Thank you all in advanced!