php – Magento将自定义字段添加到客户帐户教程问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – Magento将自定义字段添加到客户帐户教程问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4404字,纯文字阅读大概需要7分钟。
内容图文
![php – Magento将自定义字段添加到客户帐户教程问题](/upload/InfoBanner/zyjiaocheng/817/61bc6f18c7e34acfabb94ad823f6517e.jpg)
我已经完全按照第7步完成了第7步.我实际上将所有文件(可以下载的设计目录中的文件除外)放到我的app目录中.巧合的是,我也试图添加“学校”属性,所以到目前为止我还没有改变一件事.我在eav_attribute表中看到“school”.该模块在系统>配置>高级>模块输出中列为已启用.我已经重新编制索引并刷新缓存,登录和注销.当我尝试编辑客户时,我仍然看不到“学校”属性.我使用vs 1.7.是否应在客户的“帐户信息”标签中找到此字段?这个教程有什么过时的吗?
这都是代码下载,但供参考(他错过了php标签的关闭,所以我也添加了这些):
控制器/ IndexController.php
<?php
class Excellence_Profile_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
等/ config.xml中
<?xml version="1.0"?>
<config>
<modules>
<Excellence_Profile>
<version>0.1.0</version>
</Excellence_Profile>
</modules>
<frontend>
<routers>
<profile>
<use>standard</use>
<args>
<module>Excellence_Profile</module>
<frontName>profile</frontName>
</args>
</profile>
</routers>
<layout>
<updates>
<profile>
<file>profile.xml</file>
</profile>
</updates>
</layout>
</frontend>
<admin>
<routers>
<profile>
<use>admin</use>
<args>
<module>Excellence_Profile</module>
<frontName>profile</frontName>
</args>
</profile>
</routers>
</admin>
<global>
<fieldsets>
<checkout_onepage_quote>
<customer_school>
<to_customer>school</to_customer>
</customer_school>
</checkout_onepage_quote>
<customer_account>
<school>
<to_quote>customer_school</to_quote>
</school>
</customer_account>
</fieldsets>
</global>
<global>
<fieldsets>
<customer_account>
<school><create>1</create><update>1</update><name>1</name></school>
</customer_account>
</fieldsets>
</global>
<global>
<models>
<profile>
<class>Excellence_Profile_Model</class>
<resourceModel>profile_mysql4</resourceModel>
</profile>
<profile_mysql4>
<class>Excellence_Profile_Model_Mysql4</class>
<entities>
<profile>
<table>profile</table>
</profile>
</entities>
</profile_mysql4>
</models>
<resources>
<profile_setup>
<setup>
<module>Excellence_Profile</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</profile_setup>
<profile_write>
<connection>
<use>core_write</use>
</connection>
</profile_write>
<profile_read>
<connection>
<use>core_read</use>
</connection>
</profile_read>
</resources>
<blocks>
<profile>
<class>Excellence_Profile_Block</class>
</profile>
</blocks>
<helpers>
<profile>
<class>Excellence_Profile_Helper</class>
</profile>
</helpers>
</global>
</config>
型号/实体/学校
<?php
class Excellence_Profile_Model_Entity_School extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
public function getAllOptions()
{
if ($this->_options === null) {
$this->_options = array();
$this->_options[] = array(
'value' => '',
'label' => 'Choose Option..'
);
$this->_options[] = array(
'value' => 1,
'label' => 'School1'
);
$this->_options[] = array(
'value' => 2,
'label' => 'School2'
);
$this->_options[] = array(
'value' => 3,
'label' => 'School3'
);
}
return $this->_options;
}
}
?>
解决方法:
这个答案对我有帮助! Adding Custom Signup Attributes in Magento 1.7
@pragnesh
you can run following script from magento root directory, this scipt
add attribute to customer and accessible in create customer and edit
customer detail, example i have taken'mobile'
here so you can get
that attribute usinggetMobile()
method in edit customer and create
customer page…. this script also automatically add and display in
admin panel try these..
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();
内容总结
以上是互联网集市为您收集整理的php – Magento将自定义字段添加到客户帐户教程问题全部内容,希望文章能够帮你解决php – Magento将自定义字段添加到客户帐户教程问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。