Add a new column in nop_Customer table

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi,
I am facing an issue after adding a new column in nop_Customer table, the "Null" value gets inserted after registration of a user. How to resolve this? How can i get the method where i can insert the new field value through c# code?
12 years ago
Hi,

What kind of column did you added? If you need more customer data I would use the Nop_CustomerAttribute.

Check out like the customer phone function in the customer.cs. Copy the function and change the values to your own.
12 years ago
Thanks for the quick reply DonPasquale, its working now.
12 years ago
Hey can you please tell me how you resolved it?
Am trying to add new column to customer table -
Am following below URL -
https://www.nopcommerce.com/docs/73/updating-an-existing-entity-how-to-add-a-new-property.aspx

But, it's giving following error -

Invalid column name 'AreaCode'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'AreaCode'.

Source Error:

Line 240:                        where c.Email == email
Line 241:                        select c;
Line 242:            var customer = query.FirstOrDefault();
Line 243:            return customer;
Line 244:        }


Source File: D:\Projects\Ekam\ekam\Libraries\Nop.Services\Customers\CustomerService.cs    Line: 242 "
"

Am a newbie, so i don't know how to apply these to points as mentioned in that link

Recreate the database. Either your own custom SQL script or use the nopCommerce installer (blog coming soon).
Stop the development web server between schema chagnes. It caches stuff and will cause a headache.

Can anyone briefly explain the steps?

Thanks
7 years ago
We can add new field to any entity in nopcommerce.
step 1
Open Customer.cs class from Nop.Core\Domain
add this line

public string YourProperty { get; set; }


Step 2
Open CustomerModel.cs class from Nop.Admin\Models
add above line in this class.

Step 3
Open CustomerController.cs from Nop.Admin\Controller
change in PrepareCustomerModel() and ActionResult Create(). add this property in this method.

Step 4
Open Customer table from your NopCommerce database. Note: Manually add this column in table.
Add column in this table. Provide your newly added property name same as Customer.cs in Nop.Core\Domain

Change your _CreateOrUpdate.cshtml and add new property in this page. and run your project.

If you want to get to more detail about, https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=20&cad=rja&uact=8&ved=0ahUKEwiLlJDc0PfOAhWMrI8KHXLWDf44ChAWCE8wCQ&url=http%3A%2F%2Fwww.lateshtclick.com%2Fblogpost%2Fhow-to-add-new-column-in-existing-table-in-nopcommerce&usg=AFQjCNEkDPFiH-otOP_9SaHCp9-UMwsI5w&sig2=j00kZ9povXzPnR5gnDcuMQ&bvm=bv.131783435,d.c2I
7 years ago
Thank you SO much @LateshtClick for that link.  It corrects the lacking "Updating an existing entity. How to add a new property." http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442499 tutorial page which has inadequate steps.

My question is more general.  Suppose we successfully add custom fields to our db, models, etc.  Then nopCommerece version X + 1 comes along.  How do we incorporate all of the wonderful improvements of the new version without losing all of our modifications we've worked so hard to create in the previous version?
7 years ago
kramffud wrote:
Thank you SO much @LateshtClick for that link.  It corrects the lacking "Updating an existing entity. How to add a new property." http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442499 tutorial page which has inadequate steps.

My question is more general.  Suppose we successfully add custom fields to our db, models, etc.  Then nopCommerece version X + 1 comes along.  How do we incorporate all of the wonderful improvements of the new version without losing all of our modifications we've worked so hard to create in the previous version?



I think you don't need to worry about fields in your db. It will be remaining same when you will run update script.(most of the cases. But if you need any update in that update script you will able to do that.)  

But You have to move your code manually. So you should keep track/region for these extra code.
3 years ago
https://docs.nopcommerce.com/en/developer/tutorials/update-existing-entity.html?q=updating-an-existing-entity-how-to-add-a-new-property

can we do this through plugin instead of changing the NOP commerce code?
3 years ago
What is the extra field you want to add ?
What are you trying to achieve ?
There is Custom Customer Attributes
Configuration > Settings > Customer Settings
See down the bottom of https://yourwebsite.com/Admin/Setting/CustomerUser
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.