Php Magento:在注册时选择客户组
正在尝试在Magento Pro v1.11中添加组id单选按钮集 跟着Php Magento:在注册时选择客户组,php,magento,controller,Php,Magento,Controller,正在尝试在Magento Pro v1.11中添加组id单选按钮集 跟着 和 ,工作到一定程度,但组id未写入数据库 迄今为止,我的模块: 目录结构 app/code/local - WACI -- Customer --- controllers ---- AccountController.php --- etc ---- config.xml config.xml <config> <modules> <WACI_Customer&
和
,
工作到一定程度,但组id未写入数据库 迄今为止,我的模块: 目录结构
app/code/local
- WACI
-- Customer
--- controllers
---- AccountController.php
--- etc
---- config.xml
config.xml
<config>
<modules>
<WACI_Customer>
<version>0.1.0</version>
</WACI_Customer>
</modules>
<global>
<fieldsets>
<customer_account>
<group_id><create>1</create></group_id>
</customer_account>
</fieldsets>
</global>
<frontend>
<routers>
<customer>
<args>
<modules>
<WACI_Customer before="Mage_Customer_AccountController">
WACI_Customer
</WACI_Customer>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
<div class="input-box">
<label for="group_id"><?php echo $this->__('Select your customer group') ?></label><br />
<?php
$groups = Mage::helper('customer')->getGroups()->toOptionArray();
foreach ($groups as $group){
echo '<input type="radio" name="group_id" value="'.$group['value'].'" class="validate-radio" >'.$group['label'].'</input><br/>';
}
?>
</div>
0.1.0
1.
WACI_客户
AccountController.php
<?php
/**
*Customer account controller
*
* @package WACI_Customer
*/
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
class WACI_Customer_AccountController extends Mage_Customer_AccountController
{
/**
* Create customer account action
*/
public function createPostAction()
{
// contents of createPostAction(), with some extra logic
/**
* Initialize customer group id
*/
/* catch groupid at account creation */
if($this->getRequest()->getPost('group_id')){
$customer->setGroupId($this->getRequest()->getPost('group_id'));
} else {
$customer->getGroupId();
}
// rest of method
}
}
因此,带有组的单选按钮在注册时显示良好,但数据没有写入数据库,因为组在admin/manage customers
- 我真的不想修改核心文件,正如文章所描述的
- 我不确定我是否正确地覆盖了法师
class(也许有更好的方法可以做到这一点?)accountController
我搞砸了什么?请看下面的URL,我认为这对您有很大帮助 如何让客户在注册时选择客户群 在magento注册期间选择客户群 如何在magento中注册时添加客户群字段 如何在注册表中添加组 检查您的config.xml:
<frontend>
<routers>
<customer>
<args>
<modules>
<WACI_Customer before="Mage_Customer_AccountController">
WACI_Customer
</WACI_Customer>
</modules>
</args>
</customer>
</routers>
</frontend>
WACI_客户
应该是:
<frontend>
<routers>
<customer>
<args>
<modules>
<WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>
</modules>
</args>
</customer>
</routers>
</frontend>
WACI_客户
您还需要注意以下事项:
<WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>
WACI_客户
及
WACI_客户
您必须确保
和内容之间不存在空格
和
,就是这样。谢谢。Config.xml让我流鼻血。你是说71个Config.xml中的哪一个?他发布了代码,但没有发布Config.xml的位置,所以我真的不知道是哪一个..我也可以用谷歌搜索;但是我已经看过所有这些了。
<WACI_Customer before="Mage_Customer">
WACI_Customer
</WACI_Customer>