在Magento 1.7中添加自定义注册属性

时间:2013-05-17 03:09:44

标签: magento e-commerce

我已经在网上搜索了在Magento中添加自定义注册属性的教程。虽然有一些可靠的教程,我最喜欢的是这个:custom customer signup attributes但没有更新Magento 1.7。

如果有人有教程推荐或了解在Magento 1.7.x中添加自定义注册属性所需的步骤,请告诉我。

我可以告诉你,我和其他许多开发人员都会非常感激,因为这个问题也发布在Magento论坛上并记录在Wiki上,但遗憾的是只有以前版本的Magento。

3 个答案:

答案 0 :(得分:8)

您可以从magento根目录运行以下脚本,此scipt添加属性给客户并可在创建客户中访问并编辑客户详细信息,例如我已在此处'mobile'使您可以使用{{1}获取该属性编辑客户并创建客户页面的方法....此脚本也会自动添加并显示在管理面板中试试这些..

getMobile()

在字体结尾显示属性。

将以下代码添加到位于的 edit.phtml 文件中 应用程序/设计/前端/碱/默认/模板/客户/形式/ edit.phtml

define('MAGENTO', realpath(dirname(__FILE__)));

require_once MAGENTO . '/app/Mage.php';

Mage::app();



$installer = new Mage_Customer_Model_Entity_Setup('core_setup');

$installer->startSetup();

$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);

$installer->addAttribute('customer', 'mobile', array(
        'label' => 'Customer Mobile',
        'input' => 'text',
        'type'  => 'varchar',
        'forms' => array('customer_account_edit','customer_account_create','adminhtml_customer','checkout_register'),
        'required' => 0,
        'user_defined' => 1,
));

$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'mobile', 0);

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

$installer->endSetup();

答案 1 :(得分:0)

正如您的上述问题,我认为您的链接仅适用于较低版本的magento

下面的链接非常有用,可以在1.7中的注册过程中添加自定义属性

使用[customer-registration-fields-magento][1]

答案 2 :(得分:0)

我很高兴地说我能够找到解决问题的方法!在Magento论坛上发帖后没有收到回复,我决定潜入并为自己解决这个问题。我希望我的解决方案能够帮助其他可能遇到类似问题的Magento开发人员。

1。我发现以下教程非常有帮助:http://www.magentocommerce.com/wiki/5_-_modules_and_development/customers_and_accounts/registration_fields

2. 很遗憾,我的主题没有位于以下位置的register.phtml文件:app / design / frontend / default / yourtheme / template / customer / form /

3。在阅读了其他一些Stack Exchange和论坛帖子后,我发现在这种情况下,Magneto默认位于以下位置:app / design / frontend / base,其中register.phtml文件位于at /app/design/frontend/base/default/template/customer/form/register.phtml

4。这是你们中的一些人也可能遇到的问题。在想到我已经弄明白了之后,我对这个文件进行了修改......没有,没有更新前端。我试着刷新缓存,但它没有用。

5. 所以我一直在搜索并发现在我的情况下(可能在你的情况下!)register.phtml实际上存储在/ app / design / frontend / base / default / template /持久性/客户/形式/

6. 在编辑了register.phtml文件后,我正在开展业务

我希望这可以帮助那些遇到同样问题的人。如果您有任何问题,请随时更新此主题,并乐意以任何方式提供帮助。

相关问题