I need to save custom attribute(Customer) values on registration for normal registration I'm using POST method, But how can I implement the same for facebook registration.
Registration with custom attributes
<?php
require_once('../app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
if (isset($_POST['loginStatus']))
{
$loginStatus =$_POST['loginStatus']; //get login status
$customerId =$_POST['customerId']; //get customer id
$getStylistId =$_POST['getStylistId']; //get stylist id
$customerFirstName =$_POST['registerFirstname']; //get customer fname
$customerLastName =$_POST['registerLastname']; //get customer lname
$customerEmail =$_POST['registerEmail']; //get customer email
$customerPassword =$_POST['registerPassword1']; //get customer password
$get_Gender =$_POST['get_Gender']; //get gender
$styles =$_POST['styles']; //get preffered style
$daring =$_POST['daring']; //get how daring value
$weekdayStyle = $_POST['weekdayStyle']; //weekday style
$weekendStyle = $_POST['weekendStyle']; //weekend style
$nightoutStyle = $_POST['nightoutStyle']; //nightout style
$bodytypeStyle = $_POST['bodytypeStyle']; //body style
$showoffLegsStyle = $_POST['showoffLegsStyle']; //(showoff/ cover up) Legs
$showoffChestStyle = $_POST['showoffChestStyle']; //(showoff/ cover up) Chest
$showoffArmsStyle = $_POST['showoffArmsStyle']; //(showoff/ cover up) Arms
$showoffStomachStyle = $_POST['showoffStomachStyle']; //(showoff/ cover up) Stomach
$skinType =$_POST['skinType']; //Skin type
$age =$_POST['age']; //age
$heightFeet =$_POST['heightFeet']; //height feet
$heightInches =$_POST['heightInches']; //height inches
$topSize =$_POST['topSize']; //Top size
$waistSize =$_POST['waistSize']; //Waist size
$shoeSize =$_POST['showSize']; //Shoe size
$jacketSize =$_POST['jacketSize']; //Jacket size
$spendDress =$_POST['spendDress']; //Spend for Dress
$spendCoatJacket =$_POST['spendCoatJacket']; //Spend for coat&jacket
$spendBlazzers =$_POST['spendBlazzers']; //Spend for Blazzers
$spendBags =$_POST['spendBags']; //Spend for Bags
$spendShoes =$_POST['spendShoes']; //Spend for Shoes
$spendBasics =$_POST['spendBasics']; //Spend for Basics
$spendDenim =$_POST['spendDenim']; //Spend for Denim
$spendGym =$_POST['spendGym']; //Spend for Gym
$spendPants =$_POST['spendPants']; //Spend for Pants
$spendSweater =$_POST['spendSweater']; //Spend for Sweater
$preffBrands =$_POST['preffBrands']; //Preffered Brands
$lookSpecific =$_POST['lookSpecific']; //Specific look
$getStyleValues = "";
$getWeekdayStyleValues = "";
$getWeekendStyleValues = "";
$getNightoutStyleValues = "";
$getBodytypeStyleValues = "";
$getBrandtype = "";
/*Gender selection*/
if($get_Gender == 'Womenswear')
{
$gender = 2;
}
else{
$gender = 1;
}
if($loginStatus == 1)
{
$customer = Mage::getModel('customer/customer')->load($customerId);
/*Style Iteration*/
for ($i=0; $i < sizeof($styles); $i++) {
//echo "\nStyles: ".$styles[$i];
$attr_styles = 'style_preffered'; //attr code of preffered style.
$attr_styles = $customer->getResource()->getAttribute($attr_styles);
if ($attr_styles->usesSource()) {
echo "\nPreffered Style Id: ".$style_id = $attr_styles->getSource()->getOptionId($styles[$i]);
$getStyleValues = $getStyleValues.$style_id.', ';
}
}
/*Weekday Style Iteration*/
for ($j=0; $j < sizeof($weekdayStyle); $j++) {
//echo "\nWeekday styles: ".$weekdayStyle[$j];
$attr_weekday = 'weekday_style'; //attr code of preffered style.
$attr_weekday = $customer->getResource()->getAttribute($attr_weekday);
if ($attr_weekday->usesSource()) {
echo "\nWeekday Style Id: ".$weekdayStyle_id = $attr_weekday->getSource()->getOptionId($weekdayStyle[$j]);
$getWeekdayStyleValues = $getWeekdayStyleValues.$weekdayStyle_id.', ';
}
}
/*Weekend Style Iteration*/
for ($k=0; $k < sizeof($weekendStyle); $k++) {
//echo "\nWeekday styles: ".$weekendStyle[$k];
$attr_weekend = 'weekend_style'; //attr code of preffered style.
$attr_weekend = $customer->getResource()->getAttribute($attr_weekend);
if ($attr_weekend->usesSource()) {
echo "\nWeekend Style Id: ".$weekendStyle_id = $attr_weekend->getSource()->getOptionId($weekendStyle[$k]);
$getWeekendStyleValues = $getWeekendStyleValues.$weekendStyle_id.', ';
}
}
/*Nightout Style Iteration*/
for ($l=0; $l < sizeof($nightoutStyle); $l++) {
//echo "\nWeekday styles: ".$nightoutStyle[$l];
$attr_nightout = 'nightout_style'; //attr code of preffered style.
$attr_nightout = $customer->getResource()->getAttribute($attr_nightout);
if ($attr_nightout->usesSource()) {
echo "\nNightout Style Id: ".$nightoutStyle_id = $attr_nightout->getSource()->getOptionId($nightoutStyle[$l]);
$getNightoutStyleValues = $getNightoutStyleValues.$nightoutStyle_id.', ';
}
}
//$bodytypeStyle
/*Body Type Style Iteration*/
for ($m=0; $m < sizeof($bodytypeStyle); $m++) {
//echo "\nWeekday styles: ".$bodytypeStyle[$m];
$attr_bodytype = 'body_type'; //attr code of preffered style.
$attr_bodytype = $customer->getResource()->getAttribute($attr_bodytype);
if ($attr_bodytype->usesSource()) {
echo "\nBody Type Style Id: ".$bodytypeStyle_id = $attr_bodytype->getSource()->getOptionId($bodytypeStyle[$m]);
$getBodytypeStyleValues = $getBodytypeStyleValues.$bodytypeStyle_id.', ';
}
}
//showoff_arms
/*Show off ARMS*/
if($showoffArmsStyle != "")
{
$attr_showoffArms = 'showoff_arms'; //attr code of preffered style.
$attr_showoffArms = $customer->getResource()->getAttribute($attr_showoffArms);
if ($attr_showoffArms->usesSource()) {
echo "\nArms Showoff Style Id: ".$armsShowoffType_Id = $attr_showoffArms->getSource()->getOptionId($showoffArmsStyle);
$armsShowoffType = $armsShowoffType_Id;
}
}
/*Show off LEGS*/
if($showoffLegsStyle != "")
{
$attr_showoffLegs = 'showoff_legs'; //attr code of preffered style.
$attr_showoffLegs = $customer->getResource()->getAttribute($attr_showoffLegs);
if ($attr_showoffLegs->usesSource()) {
echo "\nLegs Showoff Style Id: ".$legsShowoffType_Id = $attr_showoffLegs->getSource()->getOptionId($showoffLegsStyle);
$legsShowoffType = $legsShowoffType_Id;
}
}
/*Show off CHEST*/
if($showoffChestStyle != "")
{
$attr_showoffChest = 'showoff_chest'; //attr code of preffered style.
$attr_showoffChest = $customer->getResource()->getAttribute($attr_showoffChest);
if ($attr_showoffChest->usesSource()) {
echo "\nChest Showoff Style Id: ".$chestShowoffType_Id = $attr_showoffChest->getSource()->getOptionId($showoffChestStyle);
$chestShowoffType = $chestShowoffType_Id;
}
}
/*Show off STOMACH*/
if($showoffStomachStyle != "")
{
$attr_showoffStomach = 'showoff_stomach'; //attr code of preffered style.
$attr_showoffStomach = $customer->getResource()->getAttribute($attr_showoffStomach);
if ($attr_showoffStomach->usesSource()) {
echo "\nStomach Showoff Style Id: ".$stomachShowoffType_Id = $attr_showoffStomach->getSource()->getOptionId($showoffStomachStyle);
$stomachShowoffType = $stomachShowoffType_Id;
}
}
/*top size*/
$attr_topSize = 'top_size'; //attr code of preffered style.
$attr_topSize = $customer->getResource()->getAttribute($attr_topSize);
if ($attr_topSize->usesSource()) {
echo "\nTop size Id: ".$topSize_Id = $attr_topSize->getSource()->getOptionId($topSize);
}
/*waist size*/
$attr_waistSize = 'waist_size'; //attr code of preffered style.
$attr_waistSize = $customer->getResource()->getAttribute($attr_waistSize);
if ($attr_waistSize->usesSource()) {
echo "\nWaist size Id: ".$waistSize_Id = $attr_waistSize->getSource()->getOptionId($waistSize);
}
/*shoe size*/
$attr_shoeSize = 'show_size'; //attr code of preffered style.
$attr_shoeSize = $customer->getResource()->getAttribute($attr_shoeSize);
if ($attr_shoeSize->usesSource()) {
echo "\nShoe size Id: ".$shoeSize_Id = $attr_shoeSize->getSource()->getOptionId($shoeSize);
}
/*Jacket size*/
$attr_jacketSize = 'jacket_size'; //attr code of preffered style.
$attr_jacketSize = $customer->getResource()->getAttribute($attr_jacketSize);
if ($attr_jacketSize->usesSource()) {
echo "\nJacket size Id: ".$jacketSize_Id = $attr_jacketSize->getSource()->getOptionId($jacketSize);
}
/*Brands*/
for ($n=0; $n < sizeof($preffBrands); $n++) {
//echo "\nWeekday styles: ".$preffBrands[$n];
$attr_brand = 'follow_brands'; //attr code of preffered style.
$attr_brand = $customer->getResource()->getAttribute($attr_brand);
if ($attr_brand->usesSource()) {
echo "\nBrand Id: ".$preffBrands_id = $attr_brand->getSource()->getOptionId($preffBrands[$n]);
$getBrandtype = $getBrandtype.$preffBrands_id.', ';
}
}
/*Saving Datas for logged in customer*/
$customer->setData('gender',$gender); //set gender
$customer->setData('style_preffered', $getStyleValues); //set style preffered
$customer->setData('daring_look', $daring); //daring look
$customer->setData('weekday_style', $getWeekdayStyleValues); //weekday style
$customer->setData('weekend_style', $getWeekendStyleValues); //weekend style
$customer->setData('nightout_style', $getNightoutStyleValues); //nightout style
$customer->setData('body_type', $getBodytypeStyleValues); //body type style
$customer->setData('showoff_arms', $armsShowoffType); //body type style
$customer->setData('showoff_legs', $legsShowoffType); //body type style
$customer->setData('showoff_chest', $chestShowoffType); //body type style
$customer->setData('showoff_stomach', $stomachShowoffType); //body type style
$customer->setData('skin_color', $skinType); //Skin type
$customer->setData('age', $age); //Age
$customer->setData('h_ft', $heightFeet); //Height feet
$customer->setData('h_inches', $heightInches); //Height inches
$customer->setData('top_size', $topSize_Id); //Top Size
$customer->setData('waist_size', $waistSize_Id); //Waist Size
$customer->setData('show_size', $shoeSize_Id); //Show Size
$customer->setData('jacket_size', $jacketSize_Id); //Jacket Size
$customer->setData('spend_goingout_dress', $spendDress); //Spend Dresses
$customer->setData('spend_coat_jacket', $spendCoatJacket); //Spend Jackets
$customer->setData('spend_blazzers', $spendBlazzers); //Spend Blazzers
$customer->setData('spend_handbags', $spendBags); //Spend Bags
$customer->setData('spend_shoes', $spendShoes); //Spend Shoes
$customer->setData('spend_basics', $spendBasics); //Spend Basics
$customer->setData('spend_denim', $spendDenim); //SpendDenim
$customer->setData('spend_gymwear', $spendGym); //SpendGym
$customer->setData('spend_pants_trousers', $spendPants); //SpendPants
$customer->setData('spend_sweaters_cardigans', $spendSweater); //SpendSweater
$customer->setData('follow_brands', $getBrandtype); //Brands
$customer->setData('specific_look', $lookSpecific); //Specific Look
$customer->setData('stylist_id', $getStylistId); //Stylist Id
try {
$customer->save();
echo "\nSuccess";
} catch (Exception $ex) {
echo "\nerror";
}
/*//////////////////////////////////////*/
}
else{
//echo "\nCUSTOMMER LOGGED OUT";
$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($websiteId)
->setStore($store)
->setFirstname($customerFirstName)
->setLastname($customerLastName)
->setEmail($customerEmail)
->setPassword($customerPassword);
/*Style Iteration*/
for ($i=0; $i < sizeof($styles); $i++) {
//echo "\nStyles: ".$styles[$i];
$attr_styles = 'style_preffered'; //attr code of preffered style.
$attr_styles = $customer->getResource()->getAttribute($attr_styles);
if ($attr_styles->usesSource()) {
echo "\nPreffered Style Id: ".$style_id = $attr_styles->getSource()->getOptionId($styles[$i]);
$getStyleValues = $getStyleValues.$style_id.', ';
}
}
/*Weekday Style Iteration*/
for ($j=0; $j < sizeof($weekdayStyle); $j++) {
//echo "\nWeekday styles: ".$weekdayStyle[$j];
$attr_weekday = 'weekday_style'; //attr code of preffered style.
$attr_weekday = $customer->getResource()->getAttribute($attr_weekday);
if ($attr_weekday->usesSource()) {
echo "\nWeekday Style Id: ".$weekdayStyle_id = $attr_weekday->getSource()->getOptionId($weekdayStyle[$j]);
$getWeekdayStyleValues = $getWeekdayStyleValues.$weekdayStyle_id.', ';
}
}
/*Weekend Style Iteration*/
for ($k=0; $k < sizeof($weekendStyle); $k++) {
//echo "\nWeekday styles: ".$weekendStyle[$k];
$attr_weekend = 'weekend_style'; //attr code of preffered style.
$attr_weekend = $customer->getResource()->getAttribute($attr_weekend);
if ($attr_weekend->usesSource()) {
echo "\nWeekend Style Id: ".$weekendStyle_id = $attr_weekend->getSource()->getOptionId($weekendStyle[$k]);
$getWeekendStyleValues = $getWeekendStyleValues.$weekendStyle_id.', ';
}
}
/*Nightout Style Iteration*/
for ($l=0; $l < sizeof($nightoutStyle); $l++) {
//echo "\nWeekday styles: ".$nightoutStyle[$l];
$attr_nightout = 'nightout_style'; //attr code of preffered style.
$attr_nightout = $customer->getResource()->getAttribute($attr_nightout);
if ($attr_nightout->usesSource()) {
echo "\nNightout Style Id: ".$nightoutStyle_id = $attr_nightout->getSource()->getOptionId($nightoutStyle[$l]);
$getNightoutStyleValues = $getNightoutStyleValues.$nightoutStyle_id.', ';
}
}
//$bodytypeStyle
/*Body Type Style Iteration*/
for ($m=0; $m < sizeof($bodytypeStyle); $m++) {
//echo "\nWeekday styles: ".$bodytypeStyle[$m];
$attr_bodytype = 'body_type'; //attr code of preffered style.
$attr_bodytype = $customer->getResource()->getAttribute($attr_bodytype);
if ($attr_bodytype->usesSource()) {
echo "\nBody Type Style Id: ".$bodytypeStyle_id = $attr_bodytype->getSource()->getOptionId($bodytypeStyle[$m]);
$getBodytypeStyleValues = $getBodytypeStyleValues.$bodytypeStyle_id.', ';
}
}
//showoff_arms
/*Show off ARMS*/
if($showoffArmsStyle != "")
{
$attr_showoffArms = 'showoff_arms'; //attr code of preffered style.
$attr_showoffArms = $customer->getResource()->getAttribute($attr_showoffArms);
if ($attr_showoffArms->usesSource()) {
echo "\nArms Showoff Style Id: ".$armsShowoffType_Id = $attr_showoffArms->getSource()->getOptionId($showoffArmsStyle);
$armsShowoffType = $armsShowoffType_Id;
}
}
/*Show off LEGS*/
if($showoffLegsStyle != "")
{
$attr_showoffLegs = 'showoff_legs'; //attr code of preffered style.
$attr_showoffLegs = $customer->getResource()->getAttribute($attr_showoffLegs);
if ($attr_showoffLegs->usesSource()) {
echo "\nLegs Showoff Style Id: ".$legsShowoffType_Id = $attr_showoffLegs->getSource()->getOptionId($showoffLegsStyle);
$legsShowoffType = $legsShowoffType_Id;
}
}
/*Show off CHEST*/
if($showoffChestStyle != "")
{
$attr_showoffChest = 'showoff_chest'; //attr code of preffered style.
$attr_showoffChest = $customer->getResource()->getAttribute($attr_showoffChest);
if ($attr_showoffChest->usesSource()) {
echo "\nChest Showoff Style Id: ".$chestShowoffType_Id = $attr_showoffChest->getSource()->getOptionId($showoffChestStyle);
$chestShowoffType = $chestShowoffType_Id;
}
}
/*Show off STOMACH*/
if($showoffStomachStyle != "")
{
$attr_showoffStomach = 'showoff_stomach'; //attr code of preffered style.
$attr_showoffStomach = $customer->getResource()->getAttribute($attr_showoffStomach);
if ($attr_showoffStomach->usesSource()) {
echo "\nStomach Showoff Style Id: ".$stomachShowoffType_Id = $attr_showoffStomach->getSource()->getOptionId($showoffStomachStyle);
$stomachShowoffType = $stomachShowoffType_Id;
}
}
/*top size*/
$attr_topSize = 'top_size'; //attr code of preffered style.
$attr_topSize = $customer->getResource()->getAttribute($attr_topSize);
if ($attr_topSize->usesSource()) {
echo "\nTop size Id: ".$topSize_Id = $attr_topSize->getSource()->getOptionId($topSize);
}
/*waist size*/
$attr_waistSize = 'waist_size'; //attr code of preffered style.
$attr_waistSize = $customer->getResource()->getAttribute($attr_waistSize);
if ($attr_waistSize->usesSource()) {
echo "\nWaist size Id: ".$waistSize_Id = $attr_waistSize->getSource()->getOptionId($waistSize);
}
/*shoe size*/
$attr_shoeSize = 'show_size'; //attr code of preffered style.
$attr_shoeSize = $customer->getResource()->getAttribute($attr_shoeSize);
if ($attr_shoeSize->usesSource()) {
echo "\nShoe size Id: ".$shoeSize_Id = $attr_shoeSize->getSource()->getOptionId($shoeSize);
}
/*Jacket size*/
$attr_jacketSize = 'jacket_size'; //attr code of preffered style.
$attr_jacketSize = $customer->getResource()->getAttribute($attr_jacketSize);
if ($attr_jacketSize->usesSource()) {
echo "\nJacket size Id: ".$jacketSize_Id = $attr_jacketSize->getSource()->getOptionId($jacketSize);
}
/*Brands*/
for ($n=0; $n < sizeof($preffBrands); $n++) {
//echo "\nWeekday styles: ".$preffBrands[$n];
$attr_brand = 'follow_brands'; //attr code of preffered style.
$attr_brand = $customer->getResource()->getAttribute($attr_brand);
if ($attr_brand->usesSource()) {
echo "\nBrand Id: ".$preffBrands_id = $attr_brand->getSource()->getOptionId($preffBrands[$n]);
$getBrandtype = $getBrandtype.$preffBrands_id.', ';
}
}
/*Saving Datas for logged in customer*/
$customer->setData('gender',$gender); //set gender
$customer->setData('style_preffered', $getStyleValues); //set style preffered
$customer->setData('daring_look', $daring); //daring look
$customer->setData('weekday_style', $getWeekdayStyleValues); //weekday style
$customer->setData('weekend_style', $getWeekendStyleValues); //weekend style
$customer->setData('nightout_style', $getNightoutStyleValues); //nightout style
$customer->setData('body_type', $getBodytypeStyleValues); //body type style
$customer->setData('showoff_arms', $armsShowoffType); //body type style
$customer->setData('showoff_legs', $legsShowoffType); //body type style
$customer->setData('showoff_chest', $chestShowoffType); //body type style
$customer->setData('showoff_stomach', $stomachShowoffType); //body type style
$customer->setData('skin_color', $skinType); //Skin type
$customer->setData('age', $age); //Age
$customer->setData('h_ft', $heightFeet); //Height feet
$customer->setData('h_inches', $heightInches); //Height inches
$customer->setData('top_size', $topSize_Id); //Top Size
$customer->setData('waist_size', $waistSize_Id); //Waist Size
$customer->setData('show_size', $shoeSize_Id); //Show Size
$customer->setData('jacket_size', $jacketSize_Id); //Jacket Size
$customer->setData('spend_goingout_dress', $spendDress); //Spend Dresses
$customer->setData('spend_coat_jacket', $spendCoatJacket); //Spend Jackets
$customer->setData('spend_blazzers', $spendBlazzers); //Spend Blazzers
$customer->setData('spend_handbags', $spendBags); //Spend Bags
$customer->setData('spend_shoes', $spendShoes); //Spend Shoes
$customer->setData('spend_basics', $spendBasics); //Spend Basics
$customer->setData('spend_denim', $spendDenim); //SpendDenim
$customer->setData('spend_gymwear', $spendGym); //SpendGym
$customer->setData('spend_pants_trousers', $spendPants); //SpendPants
$customer->setData('spend_sweaters_cardigans', $spendSweater); //SpendSweater
$customer->setData('follow_brands', $getBrandtype); //Brands
$customer->setData('specific_look', $lookSpecific); //Specific Look
$customer->setData('stylist_id', $getStylistId); //Stylist Id
try {
$customer->save();
echo "\nSuccess";
} catch (Exception $ex) {
echo "\nerror";
}
}
}
Facebook Registration
protected function createCustomerMultiWebsite($data, $website_id, $store_id)
{
$customer = Mage::getModel('customer/customer')->setId(null);
$customer ->setFirstname($data['firstname'])
->setLastname($data['lastname'])
->setEmail($data['email'])
->setWebsiteId($website_id)
->setStoreId($store_id)
->save()
;
$isSendPassToCustomer = Mage::getStoreConfig('fblogin/general/is_send_password_to_customer');
$newPassword = $customer->generatePassword();
$customer->setPassword($newPassword);
try{
$customer->save();
}catch(Exception $e){}
if($isSendPassToCustomer)
$customer->sendPasswordReminderEmail();
return $customer;
}