【问题标题】:How to add a custom attribute in customer account in Magento 1.6.2如何在 Magento 1.6.2 的客户帐户中添加自定义属性
【发布时间】:2012-05-25 10:23:23
【问题描述】:

我想在管理面板的客户帐户选项卡中添加自定义属性。我正在使用 magento 1.6.2。我已经阅读了很多博客,但无法实现它,因为文件 Mage/Customer/Model/Entity/Setup.php 在 CE 1.6.2 和 CE

【问题讨论】:

    标签: magento custom-fields


    【解决方案1】:

    使用它来创建一个执行此操作的模块:

    http://silksoftware.com/magento-module-creator/

    然后转到“需要添加客户属性部分”。这是不言自明的。

    玩它!这是一个非常有用的工具。您可以看到,除了制作一个提供新客户属性的模块之外,还有更多内容。在安装新模块之前还要阅读清除缓存/编译。

    【讨论】:

    • 您好 Malaki,感谢您的及时回复,我已尝试为后端页面创建模块。我选择添加客户属性(信用额度和时间范围),我可以看到在eav_attribute表中已经创建了两个属性但是后端和前端没有打开。出于安全原因,它向我显示默认情况下禁用异常打印错误。错误日志记录号:1639477309
    • 你能找出可能出错的地方吗?我在模块创建器中输入了以下参数: 需要后端页面:是 需要添加客户属性:是 输入了 2 个属性并将其他参数保留为默认值。谢谢
    • 感谢 Malaki,它正在工作,我可以创建管理模块。希望现在我能够在其上构建我的业务逻辑。
    • 没问题,如果这对你有很大帮助,你可能想接受这个答案:)
    • @SethJeremiMalaki 你是我发布该链接的英雄。
    【解决方案2】:

    magento 中 CE1.5 和 CE1.6 之间的添加客户字段没有重大变化。

    用户phtml文件位置的主要变化。检查下面的链接,它会帮助你。

    How to create new fields for customer

    【讨论】:

    • 我可以注意到 Model/Entity/Setup.php (CE 1.6.0) 中的差异,可以看到属性的数组列表,但在 CE1.6.2 中你不会找到数组列表。在 Magento 1.6.2 中,您将在 Resource/Setup.php 中找到数组列表。我什至尝试将 config.xml 文件中的路径从 Company_Modulename_Model_Entity_Setup 更改为 Company_Modulename_Model_Resource_Setup,但没有成功。
    • 嗨 Shankar,我已经完成了以下操作,如果你能告诉我哪里错了。在 config.xml 0.1.0Kritnu_Credit_Model
    • Kritnu_CreditMage_Customer_Model_Entity_Setupcore_setup连接> core_writecore_read
    • in credit/sql/credit_setup/mysql4-installation-0.1.0.php startSetup(); $setup = Mage::getModel('customer/entity_setup', 'core_setup'); $setup->addAttribute('customer', 'credit', array('type' => 'int', 'input' => 'text', 'label' => 'Credit', 'global' => 1, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'default' => '0', 'visible_on_front' => 1, 'source'=> '', ));跨度>
    • if (version_compare(Mage::getVersion(), '1.6.0', 'getResource()->getEntityType()->getDefaultAttributeSetId(); $setup->addAttributeToSet('customer', $attrSetId, 'General', 'credit'); } if (version_compare(Mage::getVersion(), '1.4.2', '>=')) { Mage::getSingleton('eav/config') ->getAttribute('customer', 'credit') -> setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register')) ->save(); } $installer->endSetup();
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    相关资源
    最近更新 更多