I'm trying to extend product entities from my plugin, and I want to add one custom field to the product entity class.
As per we know, Product entity class is partial class, so I've created one partial class in my plugin.
public partial class Product
{
public string TestProperty { get; set; }
}
And trying to get this to the controller.
var product = _productService.GetProductById(1);
product.TestProperty ="testProperty";
Now I'm wondering for TestProperty, sometimes it appears and sometimes it gives an error "TestProperty Could not found, missing ref".
Second thing,
When I Add product to update service, it's not showing any error. But at a time of build the project it's give an error.
_productService.UpdateProduct(product);
Error 1 'Nop.Core.Domain.Catalog.Product' does not contain a definition for 'TestProperty' and no extension method 'TestProperty' accepting a first argument of type 'Nop.Core.Domain.Catalog.Product' could be found (are you missing a using directive or an assembly reference?)
Am I missing something?
P.S: I've referred Proposal of a modified nopCommerce architecture to extend entities