无法在 nopcommerce 的 UrlRecord 表中插入客户 SeName

用户4949385

目前我被困在一点,当客户完成其注册过程时,我想要做的是从客户的电子邮件地址创建一个 SeName 并将其存储在 UrlRecord 表中,以便我可以导航到客户的个人资料页面。以下是我迄今为止尝试过的代码。

string CustomerSeName = "";
var CustomerModel=_customerService.GetCustomerById(_workContext.CurrentCustomer.Id);
if (CustomerModel != null)
{
       CustomerSeName = customer.ValidateSeName(CustomerSeName, CustomerModel.Email, true);
       _urlRecordService.SaveSlug(CustomerModel, CustomerSeName, 0);
}

在上面的代码中,我得到了 CustomerModel 和 CustomerSeName 中的所有值,但是当它执行 SaveSlug() 方法时,它抛出一个 Object reference not set 错误。我不知道它缺少哪个值。如果有人知道解决方案,请帮助我。提前致谢..!

拉斐尔

我尝试了您的代码,但无法编译。

ISlugSupported添加到 Customer 实体并使用此代码后,一切正常

private void GenerateCurrentCustomerSlug()
{
    var slug = _workContext.CurrentCustomer.ValidateSeName(seName: "", name: _workContext.CurrentCustomer.Email, ensureNotEmpty: true);
    _urlRecordService.SaveSlug(_workContext.CurrentCustomer, slug, languageId: 0);
}

如果没有为当前客户设置电子邮件,上述代码也有效。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

将product.GetSeName()更改为Product.SeName Nopcommerce 2.40

来自分类Dev

抱歉-您最后的操作无法在Nopcommerce的Paypal中完成

来自分类Dev

无法运行我的 nopcommerce 任务

来自分类Dev

在nopcommerce3.3中获取当前客户

来自分类Dev

在nopcommerce3.3中获取当前客户

来自分类Dev

我无法在NopCommerce中为新的管理插件调用窗口小部件

来自分类Dev

未在Nopcommerce中插入活动日志

来自分类Dev

等级价格无法正常使用(nopcommerce)

来自分类Dev

Nopcommerce MessageTemplate,无法添加方法作为令牌

来自分类Dev

如何在NopCommerce中添加新表?

来自分类Dev

新表的服务注册中的Nopcommerce错误

来自分类Dev

nopCommerce中的相关产品属性

来自分类Dev

PostgreSQL无法从表中插入无法插入

来自分类Dev

Nopcommerce MessageTemplate,无法将方法添加为令牌

来自分类Dev

codeplex-无法解析主机:nopcommerce.codeplex.com

来自分类Dev

无法上传主题中的图片。nopCommerce MVC

来自分类Dev

无法在表中插入数据

来自分类Dev

如何在Nopcommerce中覆盖视图?

来自分类Dev

在nopCommerce 3.70中引导Maga菜单

来自分类Dev

nopCommerce 3.40中的“ TypeError:$(...)。magnificPopup不是函数”

来自分类Dev

在NopCommerce中创建自定义任务

来自分类Dev

SSL 在 nopcommerce 中不起作用

来自分类Dev

无法在SAP表中插入相同的值

来自分类Dev

无法将此差异插入表中

来自分类Dev

无法在SAP表中插入相同的值

来自分类Dev

无法将列名从插入到表中

来自分类Dev

mySQL - 无法向表中插入值

来自分类Dev

无法将 xml 数据插入表中

来自分类Dev

nopcommerce中的插件和小部件之间的区别