Follow by Email

Thursday, July 7, 2011

How to add group in register form

in magento 1.5+ go to the
app\design\frontend\base\default\template\customer\form\register.phtml
add following code in the page

<div class="input-box">

<label for="group_id" class="required"><?php echo $this->__('Group') ?><em>*</em></label><br/>

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

<br /><p class="required" style="float:left;">Retailer group require admin authentication </p>

</div>


also change some code in 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();
}

11 comments:

  1. ooooh maaaan... how easy is that? and i was ripping out my hair! thanks mate!

    ReplyDelete
  2. hi, i have add the code on register page and all the Groups going to display but same problem occur when i have apply this code:
    f($this->getRequest()->getPost('group_id'))
    {
    $customer->setGroupId($this->getRequest()->getPost('group_id'));
    }
    else
    {
    $customer->getGroupId();
    }

    the group value is not saved in database.. waiting for your response

    ReplyDelete
    Replies
    1. Please check the following link hope it will help
      http://sapnandu-magento.blogspot.com/2014/01/add-customer-group-in-registration-page.html

      Delete
  3. Instead of editing magento core files how can i override base class & add the fields on the registration page?????? please Help.....

    ReplyDelete
  4. localhost/magento/shoe
    localhost/magento/furniture
    localhost/magento/computer

    I have created store for individual website.

    I know the login option of the 3 website will be the same.I dont have to make different login box.

    just for example:

    When I go :localhost/magento/shoe
    there will be a login option.
    Any customer go to that site and he can registered as well he can entered into the the shoe website.


    Similar way for next two the same case will occur.
    So here we dont need to make different login boxes.

    Upto that section i have done.

    Now there is requirement to have a Retail Shop:
    Under localhost/magento(Which is the main domain) there will a section for retailer to create an account and to login into his account.
    This retailer has the option to control above all 3 website as mentioned above.

    I want another login option for this retail shop.
    How can i do that.Please guide me

    If you still have doubt then please let me know... Thanks in advance

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Group value will be stored in db but not displayed in backend.Pls help me.

    ReplyDelete
  7. Group value will be stored in db but not displayed in backend.Pls help me.Nice to work frond end only

    ReplyDelete
  8. You can simply observe the event: customer_save_before. If you want a ready made solution you can use 'Customer Group Selector' - It allows customers to select their required customer group at registration & checkout, using group dropdown or group code.:
    http://www.magepsycho.com/customer-group-selector-switcher.html

    ReplyDelete
  9. The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
    magento development company in bangalore 

    ReplyDelete