Magento 查看“公司名称”而不是名字/姓氏

发布于 2024-09-18 21:36:46 字数 129 浏览 5 评论 0原文

Magento 是否可以通过客户的公司名称以及联系人姓名来查看/管理我们的客户,以便轻松找到他们?它用于 B2B,因此当电子邮件发出时,他们会提取客户的姓名,而不是更合适的公司名称。

这是全局设置吗?

提前致谢。

Can Magento view/manage our customers by their business name in addition to their contact names to find them easily? It is being used for B2B, so when emails go out they are pulling the customer’s name, instead of the company name which is more appropriate.

Is this a global setting?

thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

居里长安 2024-09-25 21:36:47

Magento 默认将公司名称存储在客户的地址上,因此访问起来有点困难。

您没有理由不能添加另一个客户字段以将公司名称添加到客户记录本身中。这样您就可以毫无问题地访问它,并且可以更改系统中的其他屏幕以反映它。

如果您不想这样做,您始终可以实现一种从默认地址中提取公司名称的方法,并将其默认保存到会话中,以便于检索。


编辑:更好的主意。

查看销售电子邮件模板,有两种方法用于获取客户名称:

$order->getCustomerName();
$order->getBillingAddress()->getName();

我没有看到任何对公司名称的单独引用,因此您应该能够用您自己的方法替换这两种方法并获得所需的结果结果。您需要创建自己的模块并覆盖客户/地址和销售/订单的模型(其他人已在其他地方深入介绍过这一点)。然后创建如下所示的方法:

public function getCustomerName() {
    if($this->getBillingAddress()->getCompany()) {
        return $this->getBillingAddress()->getCompany();
    }

    return parent::getCustomerName();
}

这是销售订单的示例,针对客户进行相应修改。现在,只要可用,就会使用您的公司名称,如果不可用,则后备将使用原始实施(客户名称)。

希望有帮助!

谢谢,


你关于通用应用程序的看法是正确的。如果您确实只想要电子邮件,那么需要关心的是您是否可以在需要时访问自定义功能。如果没有方便的对象,我不确定您是否能够调用您需要的任何方法。

在这种情况下有效的方法是重写下面提到的两个对象,但向它们添加 getCompanyName 方法。这样,您就可以调用正确的对象,并且可以根据需要编辑电子邮件。

Magento stores business name on the customer's address by default, so it's a little harder to get to.

There's no reason you cannot add another customer field to put the company name on the customer record itself. That way you'll have no problem accessing it, and can change other screens in the system to reflect it.

If you don't want to go to those lengths, you could always implement a method that pulls the company name from the default address, and save it into the session by default, for easier retrieval.


EDIT: Better idea.

Looking through the sales email templates, there are two methods that are used to grab a customer's name:

$order->getCustomerName();
$order->getBillingAddress()->getName();

I don't see any separate references to the company name, so you should be able to substitute these two methods for your own and get the desired outcome. You'll need to create your own module and override the models for customer/address and sales/order (others have covered this in depth elsewhere). Then create methods that look something like this:

public function getCustomerName() {
    if($this->getBillingAddress()->getCompany()) {
        return $this->getBillingAddress()->getCompany();
    }

    return parent::getCustomerName();
}

That's the example for sales order, modify accordingly for customer. Now your company names will be used whenever available, and when they aren't the fallback will be to the original implementation (customer name).

Hope that helps!

Thanks,
Joe


You are correct about the universal application. If you did want just the emails, the concern is whether you have access to your custom function where you need it. If there's no object handy, I'm not positive that you will be able to call just any method that you need to.

An approach that would work in this case would be to override the two objects mentioned below, but to instead add a getCompanyName method to them. That way, you'll have the right objects to call, and you can edit the emails specifically to taste.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文