Home  >  Forums  >  General  >  Development  >  Change query

Change query

Posted: January 24, 2017 at 9:28 AM Quote #182152
I had add a new property to Customer and new column in dbo.Customer. I can write data to the new column during registration. But when I want to see list of all customers I get a grid with empty column of my new property. I found out that methode  GetAllCustomers in CustomerService contains code:

var query = _customerRepository.Table;  

Of course there is no my new column in this query.....

But I can't find how I can change this query.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: January 24, 2017 at 9:47 AM Quote #182154
The new attributes are saved in GenericAttribute Table.

//save customer attributes
_genericAttributeService.SaveAttribute(customer, SystemCustomerAttributeNames.CustomCustomerAttributes, customerAttributesXml);

You can Get them using:

  customer.GetAttribute<string>(SystemCustomerAttributeNames.CustomCustomerAttributes, _genericAttributeService);

But you receive an xml that you have to parse with

var selectedValues = _customerAttributeParser.ParseCustomerAttributeValues(selectedAttributesXml);
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Maurizio Polidori
nopCommerce certified developer
since November 26, 2016
Posted: January 24, 2017 at 9:56 AM Quote #182156
Thanks, but my question was how to add one more column to a query. I can not find a code which generates this query.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: January 24, 2017 at 10:15 AM Quote #182157
It sounds like you already added your new property to the Customer entity so I'd guess you need to add it to the admin Customer view model and then update the PrepareCustomerModelForList method in the CustomerController to populate your property.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Regards, Pete.
Posted: January 25, 2017 at 1:58 AM Quote #182193
It was already done! But I still get empty column in my view of all customers in admin mode.
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: January 25, 2017 at 3:11 AM Quote #182198
My new property in Customer Entity is ClientNumber. The column ClientNumber in dbo.Customer is not empty.
I have add to the script in List.cshtml after   <div id="customers-grid"></div>:

<script>

....
    columns: [
....
,{
     field: "ClientNumber",
      title: "Klantnummer",
      width: 200
      } ,    
...
]    

</script>

But I still get no data in my new column in the view.

What do I miss?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.