I got a project In which I have to make a store in which when customer registered email id [email protected] domain then he/she will be consider as premium customer and I have to assign them particular product which only Premium customer can Access and other customer registered with other domain Email id will be general customer and they can not have access to premium product
For this I follow this link How to assign a group to user based on their email id on registration
and created an module based on code but it is not working Here is my Code of
app\etc\modules/Xyz.xml
<?xml version="1.0"?> <config> <modules> <Xyz_Catalog> <codePool>local</codePool> <active>true</active> </Xyz_Catalog> </modules> </config> Then Code for my app\code\local\Xyz\Catalog\etc/config.xml
<?xml version="1.0"?> <config> <global> <models> <xyzcatalog> <class>Xyz_Catalog_Model</class> </xyzcatalog> </models> <events> <customer_save_after> <observers> <change_customer_group> <type>singleton</type> <class>magento63798/observer</class> <method>ChangeCustomerGroup</method> </change_customer_group> </observers> </customer_save_after> </events> </global> </config> And code for my observer is in app\code\local\Xyz\Catalog\Model\Observer/Observer.php
<?php class Stackexchange_Magento63798_Model_Observer { public function ChangeCustomerGroup(Varien_Event_Observer $observer){ $customer=$observer->getEvent()->getCustomer(); Mage::log('My log entry'.$customer->getId(), null, 'Magento63798.log'); $premiummember=4;// 4 is the id of customer group I have created $Guestmember=5; list($user, $domain) = explode('@',$customer->getEmail()); if ($domain == 'gmail.com'): /* set Customer group as Stiudent */ $customer->setData('group_id',$StudentGroup); // use gmail else: $customer->setData('group_id',$GuestGroupId); endif; } But when I registered the user with email id of like of premium member it is not goes into premium member group but goes to general Group