Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Add customer in different group during registration in magento

If you want to add customer in different group during registration than follow this instruction.

You need to change in two files.
1) app\design\frontend\[your theme]\default\template\customer\form\register.phtml
add following code in the page

<div class="input-box">
   <label for="group_id"><?php echo $this->__('Group') ?><span class="required">*</span></label>
   <select name="group_id" id="group_id" title="<?php echo $this->__('Group') ?>" class="validate-group required-entry input-text" />
   <?php $groups = Mage::helper('customer')->getGroups()->toOptionArray(); ?>
   <?php foreach($groups as $group){ ?>
   <option value="<?php print $group['value'] ?>"><?php print $group['label'] ?></option>
   <?php } ?>
   </select>
</div>

2) app\code\core\Mage\Customer\controllers\AccountController.php

now replace $customer->getGroupId(); with

if($this->getRequest()->getPost('group_id'))
{
        $customer->setGroupId($this->getRequest()->getPost('group_id'));
}
else
{
        $customer->getGroupId();
}

This is good practise to override AccountController.php in your local directory

Please support us, Like us on Facebook.

0 comments:

Post a Comment

 

Copyright @ 2017 HKBlog.