Change query

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
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.
7 years ago
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);
7 years ago
Thanks, but my question was how to add one more column to a query. I can not find a code which generates this query.
7 years ago
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.
7 years ago
It was already done! But I still get empty column in my view of all customers in admin mode.
7 years ago
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 topic was automatically closed 365 days after the last reply. New replies are no longer allowed.