本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例5: _beforeSave
/**
* @param Varien_Object $object
* @return $this
*/
protected function _beforeSave(Varien_Object $object)
{
parent::_beforeSave($object);
$this->_changeTime($object);
return $this;
}
示例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;
}