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


PHP Mage_Eav_Model_Entity_Abstract::_beforeSave方法代码示例

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


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

示例1: _beforeSave

 /**
  * Check customer scope, email and confirmation key before saving
  *
  * @param Mage_Customer_Model_Customer $customer
  * @throws Mage_Customer_Exception
  * @return Mage_Customer_Model_Resource_Customer
  */
 protected function _beforeSave(Varien_Object $customer)
 {
     parent::_beforeSave($customer);
     if (!$customer->getEmail()) {
         throw Mage::exception('Mage_Customer', Mage::helper('Mage_Customer_Helper_Data')->__('Customer email is required'));
     }
     $adapter = $this->_getWriteAdapter();
     $bind = array('email' => $customer->getEmail());
     $select = $adapter->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email = :email');
     if ($customer->getSharingConfig()->isWebsiteScope()) {
         $bind['website_id'] = (int) $customer->getWebsiteId();
         $select->where('website_id = :website_id');
     }
     if ($customer->getId()) {
         $bind['entity_id'] = (int) $customer->getId();
         $select->where('entity_id != :entity_id');
     }
     $result = $adapter->fetchOne($select, $bind);
     if ($result) {
         throw Mage::exception('Mage_Customer', Mage::helper('Mage_Customer_Helper_Data')->__('This customer email already exists'), Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS);
     }
     // set confirmation key logic
     if ($customer->getForceConfirmed()) {
         $customer->setConfirmation(null);
     } elseif (!$customer->getId() && $customer->isConfirmationRequired()) {
         $customer->setConfirmation($customer->getRandomConfirmationKey());
     }
     // remove customer confirmation key from database, if empty
     if (!$customer->getConfirmation()) {
         $customer->setConfirmation(null);
     }
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:40,代码来源:Customer.php

示例2: _beforeSave

 /**
  * Check customer scope, email and confirmation key before saving
  *
  * @param Varien_Object $customer
  * @return Mage_Customer_Model_Entity_Customer
  * @throws Mage_Core_Exception
  */
 protected function _beforeSave(Varien_Object $customer)
 {
     parent::_beforeSave($customer);
     $select = $this->_getReadAdapter()->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email=?', $customer->getEmail());
     if ($customer->getSharingConfig()->isWebsiteScope()) {
         $select->where('website_id=?', (int) $customer->getWebsiteId());
     }
     if ($customer->getId()) {
         $select->where('entity_id !=?', $customer->getId());
     }
     if ($this->_getWriteAdapter()->fetchOne($select)) {
         Mage::throwException(Mage::helper('customer')->__('Customer email already exists'));
     }
     // set confirmation key logic
     if ($customer->getForceConfirmed()) {
         $customer->setConfirmation(null);
     } elseif (!$customer->getId() && $customer->isConfirmationRequired()) {
         $customer->setConfirmation($customer->getRandomConfirmationKey());
     }
     // remove customer confirmation key from database, if empty
     if (!$customer->getConfirmation()) {
         $customer->setConfirmation(null);
     }
     return $this;
 }
开发者ID:Rinso,项目名称:magento-mirror,代码行数:32,代码来源:Customer.php

示例3: _beforeSave

 /**
  * Also serialize additional information
  *
  * @param Varien_Object $payment
  */
 protected function _beforeSave(Varien_Object $payment)
 {
     $additionalInformation = $payment->getData('additional_information');
     if (empty($additionalInformation)) {
         $payment->setData('additional_information', null);
     } elseif (is_array($additionalInformation)) {
         $payment->setData('additional_information', serialize($additionalInformation));
     }
     parent::_beforeSave($payment);
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:15,代码来源:Payment.php

示例4: _beforeSave

 protected function _beforeSave(Varien_Object $customer)
 {
     parent::_beforeSave($customer);
     $select = $this->_getReadAdapter()->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email=?', $customer->getEmail());
     if ($customer->getSharingConfig()->isWebsiteScope()) {
         $select->where('website_id=?', (int) $customer->getWebsiteId());
     }
     if ($customer->getId()) {
         $select->where('entity_id !=?', $customer->getId());
     }
     if ($this->_getWriteAdapter()->fetchOne($select)) {
         Mage::throwException(Mage::helper('customer')->__('Customer email already exists'));
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:15,代码来源:Customer.php

示例5: _beforeSave

 /**
  * @param Varien_Object $object
  * @return $this
  */
 protected function _beforeSave(Varien_Object $object)
 {
     parent::_beforeSave($object);
     $this->_changeTime($object);
     return $this;
 }
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:10,代码来源:Abstract.php

示例6: _beforeSave

 /**
  * Check customer address before saving
  *
  * @param Varien_Object $address
  * @return Mage_Customer_Model_Resource_Address
  */
 protected function _beforeSave(Varien_Object $address)
 {
     parent::_beforeSave($address);
     $this->_validate($address);
     return $this;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:12,代码来源:Address.php


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