本文整理汇总了PHP中Mage_Core_Model_Resource_Db_Abstract::_beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Resource_Db_Abstract::_beforeSave方法的具体用法?PHP Mage_Core_Model_Resource_Db_Abstract::_beforeSave怎么用?PHP Mage_Core_Model_Resource_Db_Abstract::_beforeSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Resource_Db_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Resource_Db_Abstract::_beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (is_array($object->getChanges()) && sizeof($object->getChanges())) {
$object->setChanges(Zend_Json::encode($object->getChanges()));
}
return parent::_beforeSave($object);
}
示例2: _beforeSave
/**
* Before model save
*
* @param Mage_Core_Model_Abstract $object
* @return Enterprise_CatalogEvent_Model_Resource_Event
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (strlen($object->getSortOrder()) === 0) {
$object->setSortOrder(null);
}
return parent::_beforeSave($object);
}
示例3: _beforeSave
/**
* Add creation date to object
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getAddedAt()) {
$object->setAddedAt($this->formatDate(true));
}
return parent::_beforeSave($object);
}
示例4: _beforeSave
/**
* Processing object before save data
* Update app_code as Store + Device
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCode($object->getCodePrefix());
}
return parent::_beforeSave($object);
}
示例5: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getSortOrder()) {
$object->setSortOrder($this->_getMaxSortOrder($object) + 1);
}
return parent::_beforeSave($object);
}
示例6: _beforeSave
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedate(now());
}
return parent::_beforeSave($object);
}
示例7: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
* @throws Mage_Core_Exception
*/
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if ($date = $object->getDateFrom()) {
$object->setDateFrom($this->formatDate($date));
} else {
$object->setDateFrom(null);
}
if ($date = $object->getDateTo()) {
$object->setDateTo($this->formatDate($date));
} else {
$object->setDateTo(null);
}
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && Varien_Date::toTimestamp($object->getDateFrom()) > Varien_Date::toTimestamp($object->getDateTo())) {
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
}
$check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
if ($check) {
Mage::throwException(Mage::helper('core')->__('Your design change for the specified store intersects with another one, please specify another date range.'));
}
if ($object->getDateFrom() === null) {
$object->setDateFrom(new Zend_Db_Expr('null'));
}
if ($object->getDateTo() === null) {
$object->setDateTo(new Zend_Db_Expr('null'));
}
parent::_beforeSave($object);
}
示例8: _beforeSave
/**
* Validate website code before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Website
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
Mage::throwException(Mage::helper('core')->__('Website code may only contain letters (a-z), numbers (0-9) or underscore(_), the first character must be a letter'));
}
return parent::_beforeSave($object);
}
示例9: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
// Object validation - null values allowed
if ($object instanceof Webguys_Easytemplate_Model_Template_Data_Abstract && !is_null($object->getValue()) && !$object->isValid()) {
throw new Exception('Form data not valid');
}
return parent::_beforeSave($object);
}
示例10: _beforeSave
/**
* Perform actions before object save
*
* @param Mage_Core_Model_Abstract $object
* @return Enterprise_Reward_Model_Resource_Reward_History
*/
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
parent::_beforeSave($object);
if (is_array($object->getData('additional_data'))) {
$object->setData('additional_data', serialize($object->getData('additional_data')));
}
return $this;
}
示例11: _beforeSave
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedate(now())->setStatus(1);
$this->generateUniqueAuthKey($object);
}
return parent::_beforeSave($object);
}
示例12: _beforeSave
/**
* process multiple select fields
*
* @access protected
* @param Mage_Core_Model_Abstract $object
* @return Lionleap_Temples_Model_Resource_Temple
* @author Ultimate Module Creator
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$months = $object->getMonths();
if (is_array($months)) {
$object->setMonths(implode(',', $months));
}
return parent::_beforeSave($object);
}
示例13: _beforeSave
/**
* Before save
* @param Mage_Core_Model_Abstract $object
* @return AntoineK_Slider_Model_Resource_Slider
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreatedAt(Mage::getSingleton('core/date')->gmtDate());
}
$object->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
return parent::_beforeSave($object);
}
示例14: _beforeSave
/**
* Setting up created_at and updarted_at
*
* @param Mage_Core_Model_Abstract $object
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getCreatedAt()) {
$object->setCreatedAt($this->formatDate(time()));
}
$object->setUpdatedAt($this->formatDate(time()));
parent::_beforeSave($object);
}
示例15: _beforeSave
/**
* Sets up performed at time if needed
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Dataflow_Model_Resource_Profile_History
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getPerformedAt()) {
$object->setPerformedAt($this->formatDate(time()));
}
parent::_beforeSave($object);
return $this;
}