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.
3 anni tempo fa
How to get the value of the client attribute on the main page?
3 anni tempo fa
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?
3 anni tempo fa
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.
3 anni tempo fa
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?
3 anni tempo fa
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>
3 anni tempo fa
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.