magento注册
2015-09-06 21:44
525 查看
1.地址保存
$_custom_address=array( 'firstname'=>'Branko', 'lastname'=>'Ajzele', 'street'=>array( '0'=>'Sampleaddresspart1', '1'=>'Sampleaddresspart2', ), 'city'=>'Osijek', 'region_id'=>'', 'region'=>'', 'postcode'=>'31000', 'country_id'=>'HR',/*Croatia*/ 'telephone'=>'0038531555444', ); $customAddress=Mage::getModel('customer/address') //$customAddress=newMage_Customer_Model_Address(); $customAddress->setData($_custom_address) ->setCustomerId($customer->getId()) ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1'); try{ $customAddress->save(); } catch(Exception$ex){ //Zend_Debug::dump($ex->getMessage()); }
[/code]
2。
publicfunctioncreatePostAction()参考
得到空的customer
$customer=Mage::getModel('customer/customer')->setId(null);
if($this->getRequest()->getParam('is_subscribed',false)){ $customer->setIsSubscribed(1); }
$customer->getGroupId();
$customer->setPassword($this->getRequest()->getPost('password')); $customer->setConfirmation($this->getRequest()->getPost('confirmation')); $customer->save();
3.publicfunctionimportFromTextArray(array$row)
4.完成的新建例子
$customer_email='test@testemail.com';//emailadressthatwillpassbythequestionaire
$customer_fname='test_firstname';//wecansetatemporyfirstnamehere
$customer_lname='test_lastname';//wecansetatemporylastnamehere
$passwordLength=10;//thelenghtofautogeneratedpassword
$customer=Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($customer_email);/**Checkiftheemailexistonthesystem.*IfYES,itwillnotcreateauseraccount.*/
if(!$customer->getId()){//settingdatasuchasemail,firstname,lastname,andpassword
$customer->setEmail($customer_email);
$customer->setFirstname($customer_fname);
$customer->setLastname($customer_lname);
$customer->setPassword($customer->generatePassword($passwordLength));}
try{//thesavethedataandsendthenewaccountemail.
$customer->save();
$customer->setConfirmation(null);
$customer->save();
$customer->sendNewAccountEmail();
}catch(Exception$ex){}
5.有一个好例子
$_customer=Mage::getModel('customer/customer');
$_customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$_customer->setEmail('joe@bloggs.com');
$_customer->setFirstname('Joe');
$_customer->setLastname('bloggs');
$_customer->password_hash=md5("password123");
try{
$_customer->save();
$_customer->setConfirmation(null);
$_customer->save();
}catch(Exception$e){
//Zend_Debug::dump($e->getMessage());
}
//addtheirdetails
$address=Mage::getModel("customer/address");
$address->setCustomerId($_customer->getId());
$address->firstname=$_customer->firstname;
$address->lastname=$_customer->lastname;
$address->postcode="4999";
$address->telephone="0038531444888";
$address->company="Somecompanyt";
$address->street="Unknown";
$address->city="Unknown";
$address->country_id="AU";
$address->setIsDefaultBilling(true);
$address->save();
/*Subscribethemtothenewsletter*/
$subscriber=Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
$subscriber->setSubscriberEmail($email);
$subscriber->setSubscriberConfirmCode($subscriber->RandomSequence());
$subscriber->setStoreId(Mage::app()->getStore()->getId());
$subscriber->setCustomerId($_customer->getId());
$subscriber->save();
6.
相关文章推荐
- css制作三角形,下拉框三角形
- 摄像机模型与标定——摄像机标定
- 对称加密与非对称加密
- 吉林一村民参与车祸救援 发现被埋的死者系妻子
- magento登陆
- Codevs 3287 货车运输
- 网易阿里等抢食记账App 新生厂商认“干爹”还是被“爹干”
- 高效Linux之tar命令的使用
- 网络IP地址
- 二叉树的遍历
- Codility lesson3 1. MinAvgTwoSlice
- Fresco 源码分析(一) DraweeView-DraweeHierarchy-DraweeController(MVC) DraweeHierachy+DraweeController的分析
- 2014-2015年终总结
- java线程池(一) -- 线程基础
- spring mvc拦截器
- C程序设计----UNIX系统接口
- log4j详解
- 编写Java程序的三十个基本规则
- POJ-2195 Going Home
- 云南彝良村民河中捕鱼捞到2000余克毒品