2.65 - Problem with adding field to Table Address

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 anos atrás
Hi,

I've been trying to add a field to table Address, it all seems fine and no errors on build, however the issue is the value is not being saved into the databse.  So I guess I am missing a mapping, but I can not find it... Anyone can help shed a light?

I have used this as a template:
https://www.nopcommerce.com/docs/73/updating-an-existing-entity-how-to-add-a-new-property.aspx

What I have added to the database/source

DB
Database Change
Added column "MarketingOk" with navchar(10), null allowed.
Used MSSQL 2008 R2's Server management studo.

Domain
\Libraries\Nop.Core\Domain\Common\Address.cs
public virtual string MarketingOk { get; set; }

and in the public Clone...
MarketingOk = this.MarketingOk,


Mapping
\Libraries\Nop.Data\Mapping\Common\AddressMap.cs
this.Property(a => a.MarketingOk).HasMaxLength(10);


Model
\Presentation\Nop.Web\Models\Common\AddressModel.cs
[NopResourceDisplayName("Address.Fields.MarketingOk")]
[AllowHtml]
public string MarketingOk { get; set; }


Views
\Presentation\Nop.Web\Views\Shared\_CreateOrUpdateAddress.cshtml
Added these in the address table, under email..
@Html.LabelFor(model => model.MarketingOk)
@Html.EditorFor(model => model.MarketingOk)
@Html.ValidationMessageFor(model => model.MarketingOk)


Thank you so much for any help...
11 anos atrás
At a quick glance everything seems ok but this is what I would do:

1) Find the Controller and ActionResult method that generates the AddressModel.

2) Place a break point at the beginning of that ActionResult.

3) Launch the application and reach that page, it’ll hit your break point and right before the return View() make sure your new field is there. It’ll probably be null (if you haven’t set anything in it).

4) Let the page finish loading

5) In the same Controller, find the ActionResult that is linked to the <form>. Chances are, that ActionResult holds the same name as the initial ActionResult in addition to an [httpPost] attribute. In addition, that ActionResult should have a parameter called (AddressModel model…)

6) Place a break point on the first line of that ActionResult.

7) From the UI, click the submit button and it’ll hit your break point. Look at the parameter “model” and see if your MarketingOk property has any data

8) If so far, everything works…continue with F11 to step into or place a break point in the appropriate Service. Work your way until the Update occurs…

9) You could even start SQL Profiler and see if the appropriate SQL Query is being run…

10) Place break points in all appropriate catch()’s just to be sure

Hope this helps!
Sincerely
11 anos atrás
Thank you fro your reply and help.

Indeed I was missing some connections in two controller files.
All works good now.

Cheers!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.