本文整理汇总了PHP中Mage_Core_Model_Abstract::getDateFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getDateFrom方法的具体用法?PHP Mage_Core_Model_Abstract::getDateFrom怎么用?PHP Mage_Core_Model_Abstract::getDateFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getDateFrom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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);
}
示例2: _beforeSave
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
if ($date = $object->getDateFrom()) {
$date = Mage::app()->getLocale()->date($date, $format, null, false);
$object->setDateFrom($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
} else {
$object->setDateFrom(null);
}
if ($date = $object->getDateTo()) {
$date = Mage::app()->getLocale()->date($date, $format, null, false);
$object->setDateTo($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
} else {
$object->setDateTo(null);
}
if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && strtotime($object->getDateFrom()) > strtotime($object->getDateTo())) {
Mage::throwException(Mage::helper('core')->__('Start date can\'t 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 (is_null($object->getDateFrom())) {
$object->setDateFrom(new Zend_Db_Expr('null'));
}
if (is_null($object->getDateTo())) {
$object->setDateTo(new Zend_Db_Expr('null'));
}
parent::_beforeSave($object);
}
示例3: _beforeSave
public function _beforeSave(Mage_Core_Model_Abstract $object)
{
$object->setDateFrom($this->formatDate($object->getDateFrom()));
$object->setDateTo($this->formatDate($object->getDateTo()));
if (strtotime($object->getDateFrom()) > strtotime($object->getDateTo())) {
Mage::throwException(Mage::helper('core')->__('Start date can\'t 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'));
}
parent::_beforeSave($object);
}
示例4: _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)
{
$dateFrom = $object->getDateFrom();
$dateTo = $object->getDateTo();
if (!empty($dateFrom) && !empty($dateTo)) {
$validator = new Zend_Validate_Date();
if (!$validator->isValid($dateFrom) || !$validator->isValid($dateTo)) {
Mage::throwException(Mage::helper('core')->__('Invalid date'));
}
if (Varien_Date::toTimestamp($dateFrom) > Varien_Date::toTimestamp($dateTo)) {
Mage::throwException(Mage::helper('core')->__('Start date cannot be greater than end date.'));
}
}
$check = $this->_checkIntersection($object->getStoreId(), $dateFrom, $dateTo, $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.'));
}
parent::_beforeSave($object);
}