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.
Il y a 3 ans
How to get the value of the client attribute on the main page?
Il y a 3 ans
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?
Il y a 3 ans
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.
Il y a 3 ans
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?
Il y a 3 ans
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>
Il y a 3 ans
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.