Allot customer group according to their email id - magento

In a magento project I need to allot customer group to customer according to their email id.
Like I have customer group in admin "xxx" and "yyy"
NOw I want at time of signup if user have id abc#xxx.com, group named xxx allot to him or if he has abc#yyy.in, group "yyy" allot to him.
Please suggest me ..how can I accomplish this task or please refer any document.
Thanks!

The most likely way to succeed is to override Mage_Customer_Model_Customer and provide your own getGroupId() method. This method should check the domain of the email address ($this->getEmail()) and then both set and return the ID of the group. If it doesn't recognise the domain then pass it back to the parent to be processed as normal.

Related

What is the "customer's user ID"?

In the Preventing duplicate Items article, it mentions that you can use a specific combination of fields to determine if there are duplicate items or not. And specifically OAuth institutions, it says the combination of fields are: customer's user ID and institution_id. I'm confused what the customer's user ID is. I'm not familiar with this identifier. Can somebody explain?
The customer's user ID would be a value in your own application's business logic, not part of the Plaid API. In most Plaid use cases, alongside an Item, you would typically store some kind of user id that associates it with a specific user in your system. The logic here is saying that if the same end user in your system has multiple Items with the same institution, they are probably duplicate Items.

Group ID for "All Company" Group in Yammer

I'm using the Yammer REST API to fetch data about messages posted in our Yammer network.
I can get messages from any group by passing the group ID.
But I don't know the group ID for the All Company group.
How can I find the group ID for the All Company group?
Use https://www.yammer.com/api/v1/messages/general.json.
You can see the other built-in feed type endpoints such as my_feed and private here: http://developer.yammer.com/restapi/#rest-messages
Yammer API POST call with parameter group_id allows posting message to a group, but not to AllCompany.
Same POST call with parameter feed_id allows posting message to a group and to AllCompany group (feed).
Use feed_id instead of group_id and all as id.
first get all the groups
using this API
https://www.yammer.com/api/v1/groups.json
in that group array check out the group full name. and you can use id of that array item. that will be your group id.
Use https://www.yammer.com/api/v1/messages.json.
This will give All public messages in the user’s (whose access token is being used to make the API call henceforth referred to as current user) Yammer network. Corresponds to “All” conversations in the Yammer web interface.
also refer answer from by #mleroy in earlier message.
use "all" as feed id for All company group.
I know this post is a bit old but it might help someone.
On every group page of Yammer, there is a section called Access Options on the right had side.
Click on the link "Embed this group in your side". It will give you JS code for the group which will include Feed ID as well.
Using this api you can able access all messages
https://www.yammer.com/api/v1/messages.json
from the response json you can see the group id of all message groups.You can notice that 'group_created_id' is null for all company group.
I dont think that group id for all company is 'All',because that parameter is an integer,So just pass null.
Its a bit weird, but I found out that the group_created_id field is null when the message belongs to "All Company"
So you can use messages.json as mentioned before to get all public messages,
or if you want to search for messages by groups, you can get a list of groups ids and use :
https://www.yammer.com/api/v1/messages/in_group/{group-id}.json
and after that use messages.json, and go over the messages and search for those who has the field group_created_id set as null
Hope it will help someone someday :P
I had a similar requirement of embedding Yammer All company feed for which I needed the Feed ID and this worked for me-
feedType: "general",
feedId: "all"
Hope this helps!

Magento customer group ID

I have made some changes to Magento order email templates and code so that customers in retail and wholesale customer groups receive differently formatted email confirmations. i.e. One group receives an email showing VAT/TAX the other does not.
This works fine except for orders paid with Paypal. With a paypal order my logic for detecting the group ID is failing. Can anyone shed any light as to why this might be happening? Is the response coming back from paypal somehow not associated with the customers group? If so can I perform a check after a successful paypal ipn response to ensure the system keeps the customer in the right group.
I am retrieving the customer group from the customer/session perhaps I should be getting it directly from the database?
Any assistance would be much appreciated!
Thanks to Anton for pointing me in the right direction. After a paypal payment group ID in the session is set to 0 - not logged in!
Makes much more sense when working on events and code after an order is placed to get customer info from the saved order, so in my case the following returned the correct Group ID for me to use in order confirmation email code etc.
$_order = $this->getOrder();
// get group id from order
$groupId = $_order->getCustomerGroupId();

A panoply of queries about Magento databases

Through which file are new customers created and saved in Magento databases?
Which function is used?
Please provide me with full path locations and function names.
Also tell me about customer groups. From where and through which files/functions do customer groups get saved in Magento?
How are customers and customer groups related?
How can I "catch" customer IDs and customer group IDs from those files?
I find the file through which Magento saves New Customer-:
/magento/app/code/core/Mage/Adminhtml/controllers/CustomerController.php
In the file CustomerController.php, there is a function saveAction() which saves a customer in Magento db.
I wanted to know how to catch Newly created customer's id(I guesss i.e. Entity Id in Customer_entity table for Magento db) from that CustomerController.php file.
I tried this but it won't work for me-"
$customer_data = Mage::getModel('customer/customer')->load($customer_id);
Anybody knows how to catch customer id while creation of new customer???
Try to search here:
Mage_Customer_AccountController->createPostAction
Well class name means
(root)/app/code/core/Mage/Customer/controllers/AccountControlller
Mage_Adminhtml_Customer_GroupController
Take a look at the AccountController.php at app/code/core/Mage/Customer/controllers, it will give you an idea how customer registration is processed.
Basically an instance of Mage_Customer_Model_Customer is created, proper data is assigned to it (collected from a post form on the registraton form or received via a webservice call) and the model is saved. The internal Magento mechanics work to put this data in proper db tables.
See also create function of the Mage_Customer_Model_Customer_Api class.
customer groups are created in Mage_Adminhtml_Customer_GroupController->saveAction(), the model being used is Mage_Customer_Model_Group
actually customer group is assigned from backend,by default general group is selected for customer group, if you want to get customer groups then you can use this code Mage::helper('customer')->getGroups()->toOptionArray();
Search for this file
/YourProject/app/code/core/Mage/Customer/controllers/AccountController.php
Search for this function name
public function createPostAction() //Magento saves New Customer
This above mentioned function is responsible for new customer registration.
print_r($this->getRequest()->getPost()); //get all the post data
print_r($session); //get all the session data

MVC3 User Authentication link

In my application I have an administrator who can create Tournament objects. When the object is created the service also creates a user (based on the tournament director's info which was entered at creation). The username for the user is the director's e-mail, the password is randomly generated and then mailed to the director.
When the director logs on with his e-mail address and password, I need to be able to link him to his own tournament, in order to only allow him to edit his own tournament's details. I have tried to find a way to store the TournamentId in the default ASP Net Users database, but was unsuccessful.
I had a look at this SO question which would certainly help me, but I can't figure out how it would apply to my problem. When the user logs on, I can't put the TournamentId in the userdata seeing as I don't know it.
Should I then do a lookup in the Tournament table to see which ID corresponds to the email address entered at login and store that in the userData? It seems quite unelegant this way.
I guess you should have a CreatedBy column in your Tournament table where you store the ID of the user who created the tournament. Then when the user logged in, get his id ( may be from session ,if you store it there), Do a select query where CreatedBy=loggedInUserId .That should do the trick.

Resources