@{ Layout = "_ColumnsTwo"; var iWorkContext = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IWorkContext>(); int customerId = (await iWorkContext.GetCurrentCustomerAsync()).Id;
thank you for your help. it works, but it gets current customer id (my own id). i need to make link to send private message to customer. can you tell me how to get customer id to create link for PM?
int vendorCustomerId = 0; var iVendorService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IVendorService>(); var iCustomerSerivce = Nop.Core.Infrastructure.EngineContext.Current.Resolve<ICustomerService>(); var vendor = (await iVendorService.GetAllVendorsAsync()).Where(v => v.Name == Model.Name).FirstOrDefault(); if (vendor != null) { var customer = (await iCustomerSerivce.GetAllCustomersAsync()).Where(c => c.VendorId == vendor.Id).FirstOrDefault(); if (customer != null) vendorCustomerId = customer.Id; }
Later you can do @if (vendorCustomerId != 0) { <a href="/sendpm/@vendorCustomerId">send message to this user</a> }
Note: If you have a them installed then you may need to edit the theme version of Vendor.cshtml For example: Nop.Web\Themes\Motion\Views\Catalog\Vendor.cshtml
int vendorCustomerId = 0; var iVendorService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IVendorService>(); var iCustomerSerivce = Nop.Core.Infrastructure.EngineContext.Current.Resolve<ICustomerService>(); var vendor = (await iVendorService.GetAllVendorsAsync()).Where(v => v.Name == Model.Name).FirstOrDefault(); if (vendor != null) { var customer = (await iCustomerSerivce.GetAllCustomersAsync()).Where(c => c.VendorId == vendor.Id).FirstOrDefault(); if (customer != null) vendorCustomerId = customer.Id; }
Later you can do @if (vendorCustomerId != 0) { <a href="/sendpm/@vendorCustomerId">send message to this user</a> }
Note: If you have a them installed then you may need to edit the theme version of Vendor.cshtml For example: Nop.Web\Themes\Motion\Views\Catalog\Vendor.cshtml
int vendorCustomerId = 0; var iVendorService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IVendorService>(); var iCustomerSerivce = Nop.Core.Infrastructure.EngineContext.Current.Resolve<ICustomerService>(); var vendor = (await iVendorService.GetAllVendorsAsync()).Where(v => v.Name == Model.Name).FirstOrDefault(); if (vendor != null) { var customer = (await iCustomerSerivce.GetAllCustomersAsync()).Where(c => c.VendorId == vendor.Id).FirstOrDefault(); if (customer != null) vendorCustomerId = customer.Id; }
Later you can do @if (vendorCustomerId != 0) { <a href="/sendpm/@vendorCustomerId">send message to this user</a> }
Note: If you have a them installed then you may need to edit the theme version of Vendor.cshtml For example: Nop.Web\Themes\Motion\Views\Catalog\Vendor.cshtml
hi, can you please give the same solution but for registered user? the idea is to show pm link for sending message to the user who created the product. i want to show "pm product creator" link in productbox.cshtml
int vendorCustomerId = 0; var iVendorService = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IVendorService>(); var iProductSerivce = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IProductService>(); var iCustomerSerivce = Nop.Core.Infrastructure.EngineContext.Current.Resolve<ICustomerService>();
var product = await iProductSerivce.GetProductByIdAsync(Model.Id); if (product != null) { var vendor = (await iVendorService.GetVendorByIdAsync(product.VendorId)); if (vendor != null) { var customer = (await iCustomerSerivce.GetAllCustomersAsync()).Where(c => c.VendorId == vendor.Id).FirstOrDefault(); if (customer != null) vendorCustomerId = customer.Id; } } }
In markup
@if (vendorCustomerId != 0) { <a href="/sendpm/@vendorCustomerId">send message to this user</a> }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hai ancora qualche domanda o hai bisogno di aiuto?