How to add custom field on product details without adding database column?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hello, I need to add a custom field to product catalog without adding a new column in database or without using existing field. How can I do it?
4 years ago
What are the fields for? Are they just information only?


4 years ago
If it is for information display you could use settings
You can create a new setting called Product.CustomFieldName.X where X is the product Id
Then to access the field for say product Id 20 then get the value for the Setting Product.CustomerFieldName.20

      string CustomFieldName = string.Format("Product.CustomFieldName.{0}", productId);
      int CustomFieldValue = _settingService.GetSetting(CustomFieldName, ...

Otherwise if it is to store a customer value use Product Attributes
4 years ago
Could you provide further details for what the fields will be used for?

Keep in mind if you use the approach offered by Yidna, you want to keep your settings clean, insure to delete values when deleting products but this may lead to loss of information. You'll need to consider whether the information may be needed for future reference.
4 years ago
Use GenericAttribute
Modify the model/view/controller, or the workaround (i.e. without modifying core .cs code) can resolve the service in the view:
https://www.nopcommerce.com/boards/t/35022/is-there-a-way-to-access-product-generic-atributes-in-a-view-.aspx
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.