How to get the value of the client attribute on the main page?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 3 años
How to get the value of the client attribute on the main page?
Hace 3 años
gnikitsin wrote:
How to get the value of the client attribute on the main page?

Would you be more specific?
"client " = Customer?
Which attribute?
"main page" = home page?    Where? (header, footer, etc.?)
What version of nopCommerce?
Hace 3 años
New York wrote:
How to get the value of the client attribute on the main page?
Would you be more specific?
"client " = Customer?
Which attribute?
"main page" = home page?    Where? (header, footer, etc.?)
What version of nopCommerce?

sorry.
yes, customer
attribute, list in @Html.Partial("_CustomerAttributes", Model.CustomerAttributes)
yes, for the homepage (body, any area in the view)
thanks.
Hace 3 años
gnikitsin wrote:
How to get the value of the client attribute on the main page?
Would you be more specific?
"client " = Customer?
Which attribute?
"main page" = home page?    Where? (header, footer, etc.?)
What version of nopCommerce?
sorry.
yes, customer
attribute, list in @Html.Partial("_CustomerAttributes", Model.CustomerAttributes)
yes, for the homepage (body, any area in the view)
thanks.


Do you have any thoughts?
Hace 3 años
gnikitsin wrote:
@Html.Partial("_CustomerAttributes", Model.CustomerAttributes)

To use this you need to change the model in code

You can do this in the .cshtml
@using Nop.Core;
@using Nop.Services.Common;
@using Nop.Core.Infrastructure;
@using  Nop.Core.Domain.Customers;
@{
    var _genericAttributeService = EngineContext.Current.Resolve<IGenericAttributeService>();
    var _workContext = EngineContext.Current.Resolve<IWorkContext>();
    var firstname = _genericAttributeService.GetAttribute<string>(_workContext.CurrentCustomer, NopCustomerDefaults.FirstNameAttribute);
    var lastname = _genericAttributeService.GetAttribute<string>(_workContext.CurrentCustomer, NopCustomerDefaults.LastNameAttribute);
}

<div>
    Name=@firstname @lastname
</div>
Hace 3 años
Note that 'custom' attributes are stored as an XML string.  There is a method in Customer Service code that can help parse it out.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.