加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php – Magento:在注册时选择客户组

发布时间:2020-05-25 08:40:24 所属栏目:PHP 来源:互联网
导读:尝试在Magento Pro v1.11中添加group_id单选按钮 跟随着 http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html和 http://developersindia.info/magento/magento-override-frontend-controller.htm

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

跟随着
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没有写入数据库.

我的模块,到目前为止:

目录结构

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

    }

}

主题../持续性/客户/表格/ 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>

因此,组中的单选按钮在注册时显示正常,但数据未写入数据库,因为组仍然在管理/管理客户中显示为一般

>我真的不想修改核心文件,正如文章所描述的那样,
>我不确定我是否正确地覆盖了法师
accountController类(也许是更好的方法吗?)

我搞砸了什么?

检查你的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>之间没有空格.和内容和< / tag>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读