当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Customer_Model_Customer::_afterSave方法代码示例

本文整理汇总了PHP中Mage_Customer_Model_Customer::_afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Customer::_afterSave方法的具体用法?PHP Mage_Customer_Model_Customer::_afterSave怎么用?PHP Mage_Customer_Model_Customer::_afterSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Customer_Model_Customer的用法示例。


在下文中一共展示了Mage_Customer_Model_Customer::_afterSave方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _afterSave

 /**
  * Creates a new API user, copied from the maintainer data
  * that was actually created.
  *
  * @return Faett_Channel_Model_Customer The user created before
  */
 public function _afterSave()
 {
     // try to load an API user with the email of the created user
     $maintainer = Mage::getModel('channel/maintainer')->loadByEmail($this->getEmail());
     // check if already an API user with the email exists
     if (!$maintainer->userExists()) {
         // if not, copy the user's data
         $maintainer->setFirstname($this->getFirstname());
         $maintainer->setLastname($this->getLastname());
         $maintainer->setUsername($this->hashPassword($this->getEmail()));
         $maintainer->setEmail($this->getEmail());
         // save with password copied from user
         $maintainer->saveWithCopiedPassword($this);
         // check if the default role ID is set
         if ($defaultRoleId = $this->_getDefaultRole()) {
             // set the role ID
             $maintainer->setRoleId($defaultRoleId);
             // check if the API user already has this role
             // (should usally never happen)
             if (!$maintainer->roleUserExists()) {
                 // add the user to the role
                 $maintainer->add();
             }
         }
     }
     // invoke the _afterSave() method of the parent class
     return parent::_afterSave();
 }
开发者ID:BGCX067,项目名称:faett-channel-svn-to-git,代码行数:34,代码来源:Customer.php

示例2: _afterSave

 protected function _afterSave()
 {
     parent::_afterSave();
     if (!$this->hasDataChanges()) {
         return $this;
     }
     $this->_updatePasswordHistory();
     return $this;
 }
开发者ID:all-bear,项目名称:magento.pci_password,代码行数:9,代码来源:Customer.php

示例3: _afterSave

 protected function _afterSave()
 {
     $oAttribute = Mage::getModel('aitcheckoutfields/aitcheckoutfields');
     if (Mage::registry('aitoc_customer_to_save') && !Mage::registry('aitoc_customer_saved')) {
         $customerId = $this->getId();
         $oAttribute->saveCustomerData($customerId);
         $oAttribute->clearCheckoutSession('register');
         Mage::unregister('aitoc_customer_to_save');
         Mage::register('aitoc_customer_saved', true);
         Mage::dispatchEvent('aitcfm_customer_save_after', array('customer' => $this, 'checkoutfields' => $this->getCustomFields()));
     }
     $oAttribute->clearCheckoutSession('register');
     return parent::_afterSave();
 }
开发者ID:finelinePG,项目名称:finelink-dev,代码行数:14,代码来源:FrontCustomerCustomer.php

示例4: _afterSave

 /**
  * Processing object after save data
  * (override from an abstract parent)
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _afterSave()
 {
     //If the customer is new (hence not having an id before) get applicable rules,
     //and create a transfer for each one
     $isNew = false;
     if ($this->isNewCustomer($this->getId())) {
         $isNew = true;
         $this->oldId = $this->getId();
         //This stops multiple triggers of this function
         $this->createTransferForNewCustomer();
     }
     Mage::getSingleton('rewards/session')->setCustomer($this);
     if ($isNew) {
         if (Mage::helper('rewards/dispatch')->smartDispatch('rewards_customer_signup', array('customer' => $this))) {
             Mage::getSingleton('rewards/session')->triggerNewCustomerCreate($this);
             Mage::dispatchEvent('rewards_new_customer_create', array('customer' => &$this));
         }
     }
     return parent::_afterSave();
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:26,代码来源:Customer.php

示例5: _afterSave

 protected function _afterSave()
 {
     if ($this->_fileAttributes) {
         $deleteFiles = Mage::app()->getRequest()->getPost('amcustomerattr_delete');
         foreach ($this->_fileAttributes as $id => $attributeCode) {
             if (isset($_FILES['amcustomerattr_' . $attributeCode]['error']) && UPLOAD_ERR_OK == $_FILES['amcustomerattr_' . $attributeCode]['error']) {
                 try {
                     $fileName = $_FILES['amcustomerattr_' . $attributeCode]['name'];
                     $uploader = new Varien_File_Uploader('amcustomerattr_' . $attributeCode);
                     $uploader->setAllowRenameFiles(false);
                     $uploader->setFilesDispersion(false);
                     $destinationFolder = Mage::helper('amcustomerattr')->getAttributeFileUrl($fileName);
                     $fileName = Mage::helper('amcustomerattr')->cleanFileName($fileName);
                     $uploader->save($destinationFolder . $fileName[1] . DS . $fileName[2] . DS, $fileName[3]);
                 } catch (Exception $error) {
                     $e = new Mage_Customer_Exception(Mage::helper('amcustomerattr')->__('An error occurred while saving the file: ' . $error->getMessage()));
                     if (method_exists($e, 'setMessage')) {
                         $e->setMessage(Mage::helper('amcustomerattr')->__('An error occurred while saving the file: ' . $error));
                     }
                     throw $e;
                 }
                 if ($this->_savedFileNames[$attributeCode]) {
                     Mage::helper('amcustomerattr')->deleteFile($this->_savedFileNames[$attributeCode]);
                 }
             }
             if ($deleteFiles && $deleteFiles[$attributeCode] && $this->_savedFileNames[$attributeCode] === $deleteFiles[$attributeCode]) {
                 Mage::helper('amcustomerattr')->deleteFile($deleteFiles[$attributeCode]);
             }
             unset($_FILES['amcustomerattr_' . $attributeCode]);
         }
     }
     if (!$this->getOrigId() && !Mage::registry('amcustomerattr_customer_registry_dispatched')) {
         Mage::register('amcustomerattr_customer_registry_dispatched', true);
         Mage::dispatchEvent('amcustomerattr_customer_registry', array('model' => $this));
     }
     Mage::getSingleton('customer/session')->unsetData('amcustomerattr');
     /*
      * send notification upon new user registration to admin
      */
     $origData = $this->getOrigData();
     if ($origData === null) {
         // new user registration will be
         $notified = Mage::registry('AdminNotifiedAboutNewUser');
         if (Mage::getStoreConfig('amcustomerattr/activation/notify_admin', $this->getStoreId()) && !$notified) {
             Mage::register('AdminNotifiedAboutNewUser', '1');
             $translate = Mage::getSingleton('core/translate');
             $translate->setTranslateInline(false);
             $template = Mage::getStoreConfig('amcustomerattr/activation/email_template_admin', $this->getStoreId());
             $template = $template ? $template : 'amasty_amcustomerattr_activation_email_template_admin';
             $emails = Mage::getStoreConfig('amcustomerattr/activation/admin_email', $this->getStoreId());
             foreach (explode(',', $emails) as $email) {
                 $email = trim($email);
                 $tpl = Mage::getModel('core/email_template');
                 $tpl->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('amcustomerattr/activation/admin_sender', $this->getStoreId()), $email, 'Admin notification', array('customer_name' => $this->getName(), 'customer_id' => $this->getEntityId(), 'created_at' => date('Y-m-d', $this->getCreatedAtTimestamp()), 'customer' => $this), $this->getStoreId());
                 $tpl = null;
             }
             $translate->setTranslateInline(true);
         }
     }
     /*
      * send notification about activation to user
      */
     $payment_post = Mage::app()->getRequest()->getPost('payment');
     //exclude checkout pages
     if (Mage::getStoreConfig('amcustomerattr/activation/notify_customer', $this->getStoreId()) && !$payment_post && $this->getOrigData('am_is_activated') != $this->getData('am_is_activated') && self::ACTIVATION_STATUS_ACTIVATED == $this->getData('am_is_activated')) {
         $notified = Mage::registry('CustomerNotifiedAboutActivation');
         if (!$notified) {
             Mage::register('CustomerNotifiedAboutActivation', '1');
             $translate = Mage::getSingleton('core/translate');
             $translate->setTranslateInline(false);
             $template = Mage::getStoreConfig('amcustomerattr/activation/email_template_customer', $this->getStoreId());
             $template = $template ? $template : 'amasty_amcustomerattr_activation_email_template_customer';
             $tpl = Mage::getModel('core/email_template');
             $tpl->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('amcustomerattr/activation/customer_sender', $this->getStoreId()), $this->getEmail(), 'Customer notification', array('customer_name' => $this->getName(), 'customer_id' => $this->getEntityId(), 'email' => $this->getEmail(), 'created_at' => $this->getCreatedAtTimestamp(), 'customer' => $this), $this->getSoreId());
             $tpl = null;
             $translate->setTranslateInline(true);
         }
     } else {
         if ($origData === null && Mage::getStoreConfig('amcustomerattr/activation/activation_required', $this->getStoreId())) {
             if (!Mage::getStoreConfig('amcustomerattr/activation/auto_activation', $this->getStoreId()) || Mage::getStoreConfig('amcustomerattr/activation/auto_activation', $this->getStoreId()) && Mage::getStoreConfig('amcustomerattr/activation/enabled_customer_groups', $this->getStoreId()) && self::ACTIVATION_STATUS_ACTIVATED != $this->getAmIsActivated()) {
                 $this->setIsLoggedIn(true);
                 Mage::getSingleton('customer/session')->logout();
                 $customerSession = Mage::getSingleton('customer/session');
                 $customerSession->unsetAll();
                 $customerSession->getCookie()->delete($customerSession->getSessionName());
                 if (!Mage::registry('CustomerNotificationAboutActivation') && Mage::getStoreConfig('amcustomerattr/activation/registration_notice', $this->getStoreId())) {
                     Mage::register('CustomerNotificationAboutActivation', 1);
                     Mage::getSingleton('core/session')->addNotice(Mage::getStoreConfig('amcustomerattr/activation/registration_notice', $this->getStoreId()));
                 }
             }
         }
     }
     parent::_afterSave();
 }
开发者ID:guohuadeng,项目名称:stampApp,代码行数:94,代码来源:Customer.php

示例6: _afterSave

 /**
  * (non-PHPdoc)
  * @see Mage_Core_Model_Abstract::_afterSave()
  */
 public function _afterSave()
 {
     if ($this->getId()) {
         if ($this->getData('customer_type') == 'vendor') {
             if (!empty($this->vendorModel)) {
                 $this->vendorModel->addData($this->getData());
                 $this->vendorModel->setCustomerId($this->getId());
                 // create account for vendor
                 $vendorRole = Mage::helper('smvendors')->getVendorRole();
                 $data = array('username' => $this->getEmail(), 'email' => $this->getEmail(), 'firstname' => $this->getFirstname(), 'lastname' => $this->getLastname(), 'is_active' => $this->vendorModel->getVendorStatus(), 'roles' => array($vendorRole));
                 $newPassword = $this->getData('user_password');
                 if (!empty($newPassword)) {
                     $data['password'] = $newPassword;
                     $data['password_confirmation'] = $newPassword;
                 }
                 if ($data) {
                     $id = $this->vendorModel->getUserId();
                     $model = Mage::getModel('admin/user')->load($id);
                     if (!$model->getIsActive() && $data['is_active']) {
                         $this->sendNewAccountEmail('approved', '', Mage::helper('smvendors')->getDefaultStoreId());
                     }
                     $model->addData($data);
                     $result = $model->validate();
                     if (is_array($result)) {
                         Mage::getSingleton('adminhtml/session')->setUserData($data);
                         foreach ($result as $message) {
                             Mage::getSingleton('adminhtml/session')->addError($message);
                         }
                     }
                     try {
                         $model->save();
                         if ($uRoles = $data['roles']) {
                             if (1 == sizeof($uRoles)) {
                                 $model->setRoleIds($uRoles)->setRoleUserId($model->getUserId())->saveRelations();
                             } elseif (sizeof($uRoles) > 1) {
                                 $rs = array();
                                 $rs[0] = $uRoles[0];
                                 $model->setRoleIds($rs)->setRoleUserId($model->getUserId())->saveRelations();
                             }
                         }
                         $this->vendorModel->setUserId($model->getUserId());
                         $passwordHash = trim($this->getPasswordHash());
                         if (!empty($passwordHash)) {
                             //print_r($this->getData());die;
                             $resource = Mage::getSingleton('core/resource');
                             $writeConnection = $resource->getConnection('core_write');
                             $tableUser = $resource->getTableName('admin/user');
                             $query = "UPDATE {$tableUser} SET password = '{$passwordHash}' WHERE user_id = " . (int) $model->getUserId();
                             $writeConnection->query($query);
                         }
                         Mage::getSingleton('adminhtml/session')->setUserData(false);
                     } catch (Mage_Core_Exception $e) {
                         Mage::getSingleton('adminhtml/session')->addError($this->__('Customer is saved, but this error happened: ' . $e->getMessage()));
                         Mage::logException($e);
                     }
                 }
                 $this->vendorModel->save();
             }
         }
     }
     return parent::_afterSave();
 }
开发者ID:shashankkanungo,项目名称:magento,代码行数:66,代码来源:SM_Vendors_Model_Override_Customer.php


注:本文中的Mage_Customer_Model_Customer::_afterSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。