Magento的:选择客户组在登记时(Magento: Select Customer Group

2019-06-27 14:09发布

如果添加GROUP_ID单选按钮在Magento专业版V1.11设置

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

所以,用组单选按钮显示在登记罚款,但数据没有被写入数据库,为组仍显示为一般的admin/manage customers

  • 我真的不希望修改核心文件,作为文章介绍,
  • 我不能肯定我正确覆盖法师accountController类(也许那里有一个更好的方式来做到这一点?)

我是什么打乱?

Answer 1:

检查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>content</tag>



Answer 2:

请参见下面的网址,我认为这是非常全面帮助你。

如何让客户在注册时选择的客户群

http://www.magentocommerce.com/boards/viewthread/24208/

在Magento注册期间选择客户组

http://sabujcse.wordpress.com/2010/03/09/selecting-customer-group-during-registration-in-magento/

如何添加客户群领域,而在Magento注册

http://xhtmlandcsshelp.blogspot.in/2010/12/add-customer-group-while-register-in.html

如何添加组报名登记表

http://sapnandu-magento.blogspot.in/2011/07/how-to-add-group-in-register-form.html



文章来源: Magento: Select Customer Group at Registration