gpt4 book ai didi

magento - 如何在 magento 的交易电子邮件模板中使用自定义客户变量?

转载 作者:行者123 更新时间:2023-12-04 05:38:12 25 4
gpt4 key购买 nike

我向客户添加了一些自定义变量,我想在电子邮件模板中使用它们。

以下是我如何在安装程序中向客户添加变量的示例:

$setup->addAttribute('customer', 'companyname', array(
'input' => 'text',
'type' => 'varchar',
'label' => 'Company name',
'visible' => 1,
'required' => 1,
'user_defined' => 1,
));

$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'companyname',
'999' //sort_order
);

$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'companyname');
$oAttribute->setData('used_in_forms', array('adminhtml_customer','customer_account_create'));
$oAttribute->save();

我尝试在电子邮件模板中使用此变量:
{{var order.getCustomer().getCompanyname()}}

但它没有显示。如何使它工作?

最佳答案

我用如下代码完成了类似的任务:

$setup->addAttribute('customer', 'attr_name', array(
'type' => 'int',
'input' => 'select',
'label' => 'Attr label',
'global' => 1,
'visible' => 1,
'required' => 1,
'default' => '0',
'user_defined' => 1,
'visible_on_front' => 1,
));
if (version_compare(Mage::getVersion(), '1.6.0', '<='))
{
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$setup->addAttributeToSet('customer', $attrSetId, 'General', 'attr_name');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>='))
{
Mage::getSingleton('eav/config')
->getAttribute('customer', 'attr_name')
->setData('used_in_forms', array('customer_account_create'))
->save();
}

接下来在“订购新产品”电子邮件中对其进行了测试(现在) {{var order.getCustomer().getAttrName()}}并获得了正确的值(value)。
试试吧,也许对你有帮助。

关于magento - 如何在 magento 的交易电子邮件模板中使用自定义客户变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11645127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com