Magento:在注册时选择客户组 [英] Magento: Select Customer Group at Registration

查看:145
本文介绍了Magento:在注册时选择客户组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试添加 Magento Pro v1.11中设置的 group_id 单选按钮

Trying to add a group_id radio button set in Magento Pro v1.11

br>
http://phpmagento.blogspot。 com / 2012/01 / how-to-show-customer-group-selecter-in.html

http://developersindia.info/magento/magento-override-frontend-controller.html
这是一个点,但是group_id没有写入到

Following along with
http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html and
http://developersindia.info/magento/magento-override-frontend-controller.html,
which is working to a point, but the group_id is not getting written to the db.

我的模块,到目前为止:

my module, thus far:

目录结构

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>





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

    }

}







theme ../ persistent / customer / form / register.phtml

<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>

因此,带有组的单选按钮在注册时显示得很好,写入数据库,作为组仍然显示为管理/管理客户

So, the radio buttons with the groups show up fine at registration, but the data isn't being written to the db, as group still shows as general in the admin/manage customers


  • 我真的不想修改核心文件,如文章所述,

  • 我不确定我是否正确覆盖mage
    accountController class(也许theres是更好的方法吗?)

  • I don't really want to modify core files, as the article describes,
  • I'm not certain that I'm properly overwriting the mage accountController class (maybe theres a better way to do this?)

I mucking up?

推荐答案

检查您的config.xml:

Check your config.xml:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <WACI_Customer before="Mage_Customer_AccountController">
                        WACI_Customer
                    </WACI_Customer>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

应为:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

您还需要注意:

<WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>

<WACI_Customer before="Mage_Customer">
    WACI_Customer
</WACI_Customer>

您必须确保< tag& code>和内容< / tag>

这篇关于Magento:在注册时选择客户组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆