本文整理汇总了PHP中Mage_Core_Model_Abstract::_beforeSave方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::_beforeSave方法的具体用法?PHP Mage_Core_Model_Abstract::_beforeSave怎么用?PHP Mage_Core_Model_Abstract::_beforeSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::_beforeSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
protected function _beforeSave()
{
if ($storeId = $this->getStoreId()) {
$defaultProductFile = Mage::getModel('productfile/productfile')->load($this->getId());
$productFileAttributes = $this->getProductFlieAttributes();
foreach ($productFileAttributes as $attribute) {
if ($this->getData($attribute . '_default')) {
$this->setData($attribute . '_in_store', false);
} else {
$this->setData($attribute . '_in_store', true);
$this->setData($attribute . '_value', $this->getData($attribute));
}
$this->setData($attribute, $defaultProductFile->getData($attribute));
}
/*if (($this->getData('filename_in_store')==true) && ($this->getData('filename_value')!= NULL)){
try {
$uploader = new Varien_File_Uploader('filename');
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(true);
$path = Mage::getBaseDir('media') . DS .'productfile' ;
$uploader->save($path, $this->getData('filename_value'));
} catch (Exception $e) {
}
}*/
}
return parent::_beforeSave();
}
示例2: _beforeSave
protected function _beforeSave()
{
if ($this->_mediumData) {
$this->setData('medium_json', $this->_mediumData->toJson());
}
parent::_beforeSave();
}
示例3: _beforeSave
protected function _beforeSave()
{
if (!$this->getId()) {
Mage::register('amorderattach_add_field', true, true);
}
return parent::_beforeSave();
}
示例4: _beforeSave
protected function _beforeSave()
{
parent::_beforeSave();
$this->_updateTimestamps();
$this->_prepareUrlKey();
return $this;
}
示例5: _beforeSave
/**
* before save anymarket orders
*
* @access protected
* @return DB1_AnyMarket_Model_Anymarketorders
*/
protected function _beforeSave()
{
parent::_beforeSave();
$now = Mage::getSingleton('core/date')->gmtDate();
if ($this->isObjectNew()) {
$this->setCreatedAt($now);
}
$this->setUpdatedAt($now);
$stores = $this->getStores();
if ($stores != null) {
if (is_array($stores)) {
$storeID = reset($stores);
}
if (!is_string($storeID) && !is_integer($storeID)) {
$this->setStores(array());
}
}
if ($this->getNmoStatusInt() == 'ERROR 02') {
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($this->getId());
if ($this->getNmoIdSeqAnymarket() == "" || $this->getNmoIdSeqAnymarket() == null) {
$this->setNmoIdSeqAnymarket($anymarketorders->getNmoIdSeqAnymarket());
}
if ($this->getNmoIdAnymarket() == "" || $this->getNmoIdAnymarket() == null) {
$this->setNmoIdAnymarket($anymarketorders->getNmoIdAnymarket());
}
}
return $this;
}
示例6: _beforeSave
/**
* Event triggered before save()
*/
protected function _beforeSave()
{
if (!$this->getPageType()) {
Mage::throwException('Missing Page Type');
}
return parent::_beforeSave();
}
示例7: _beforeSave
/**
* @return Firegento_FlexCms_Model_Content_Data
*/
protected function _beforeSave()
{
if (is_array($this->getData('content'))) {
$this->setData('content', Zend_Json::encode($this->getData('content')));
}
return parent::_beforeSave();
}
示例8: _beforeSave
/**
* Encrypts information before saving to DB
*
*/
protected function _beforeSave()
{
foreach (array('username', 'password') as $field) {
$this->setData($field, $this->encrypt($this->getData($field)));
}
return parent::_beforeSave();
}
示例9: _beforeSave
protected function _beforeSave()
{
if (Mage::helper('core')->isModuleEnabled('MageB2B_CustomerId') && !$this->getCustomerId()) {
$_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c = Mage::getModel('customer/customer')->load($this->getEntityId());
if ($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() && Mage::getStoreConfig('customer_id/customer_id/auto_increment')) {
$_b80cbfb11fdc80a0dabd8069a0fd063d9d896285 = array();
$_205d95c001c842f933e3b55fa4e902d5d2fdd0af = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('entity_id', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId());
foreach ($_205d95c001c842f933e3b55fa4e902d5d2fdd0af as $_4e45fa4f3249d9c3cc1314ed89922593008cf117) {
$_b80cbfb11fdc80a0dabd8069a0fd063d9d896285[] = $_4e45fa4f3249d9c3cc1314ed89922593008cf117->getCustomerId();
}
$_205d95c001c842f933e3b55fa4e902d5d2fdd0af = Mage::getModel('sublogin/sublogin')->getCollection()->addFieldToFilter('entity_id', $_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getId())->addOrder('id', 'asc');
$_e5063eb1568e4b8089f8c18b623e0363b782b74c = 1;
while (in_array($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() . '-' . $_e5063eb1568e4b8089f8c18b623e0363b782b74c, $_b80cbfb11fdc80a0dabd8069a0fd063d9d896285)) {
$_e5063eb1568e4b8089f8c18b623e0363b782b74c++;
}
$this->setCustomerId($_b803c43bc8b3ef64b7d19b78f670cdbd11dacf8c->getCustomerId() . '-' . $_e5063eb1568e4b8089f8c18b623e0363b782b74c);
}
}
$_36276558859e15204f0e389493057edad0cad1cf = Mage::getModel('newsletter/subscriber')->loadByEmail($this->getEmail());
if ((int) $this->getData('is_subscribed')) {
if (!$_36276558859e15204f0e389493057edad0cad1cf->getId()) {
Mage::getModel('newsletter/subscriber')->subscribe($this->getEmail());
}
} else {
$_36276558859e15204f0e389493057edad0cad1cf->unsubscribe();
}
if (!$this->getData('expire_date') || $this->getData('expire_date') === null || $this->getData('expire_date') == '0000-00-00') {
$this->setExpireDate(new Zend_Db_Expr('0000-00-00'));
}
parent::_beforeSave();
}
示例10: _beforeSave
protected function _beforeSave()
{
if (is_array($this->getCategoryIds())) {
$this->setCategoryIds(implode(',', $this->getCategoryIds()));
}
return parent::_beforeSave();
}
示例11: _beforeSave
protected function _beforeSave()
{
parent::_beforeSave();
$actionsXML = $this->getData('actions_xml');
if (strlen($actionsXML) < 0 && @simplexml_load_string('<data>' . $actionsXML . '</data>', null, LIBXML_NOERROR) === false) {
Mage::throwException(Mage::helper("dataflow")->__("Actions XML is not valid."));
}
if (is_array($this->getGuiData())) {
$data = $this->getData();
$guiData = $this->getGuiData();
if (isset($guiData['file']['type']) && $guiData['file']['type'] == 'file') {
if (strlen($guiData['file']['path']) == 0 || strlen($guiData['file']['path']) == 1 && in_array($guiData['file']['path'], array('\\', '/', '.', '!', '@', '#', '$', '%', '&', '*', '~', '^'))) {
$guiData['file']['path'] = self::DEFAULT_EXPORT_PATH;
}
if (strlen($guiData['file']['filename']) == 0) {
$guiData['file']['filename'] = self::DEFAULT_EXPORT_FILENAME . $data['entity_type'] . '.' . ($guiData['parse']['type'] == 'csv' ? $guiData['parse']['type'] : 'xml');
}
$this->setGuiData($guiData);
}
// echo '<pre>';
// print_r($this->getGuiData());
$this->_parseGuiData();
$this->setGuiData(serialize($this->getGuiData()));
}
if ($this->_getResource()->isProfileExists($this->getName(), $this->getId())) {
Mage::throwException(Mage::helper("dataflow")->__("Profile with the same name already exists."));
}
}
示例12: _beforeSave
/**
* Set some data automatically before saving model
*
* @return Enterprise_Logging_Model_Event
*/
protected function _beforeSave()
{
$this->_calculateDifference();
$this->setOriginalData(serialize($this->getOriginalData()));
$this->setResultData(serialize($this->getResultData()));
return parent::_beforeSave();
}
示例13: _beforeSave
/**
* Processing object before save data
*
* @return Mage_Core_Model_Abstract
*/
protected function _beforeSave()
{
if (!$this->getRuleId() && $this->_rule instanceof Mage_SalesRule_Model_Rule) {
$this->setRuleId($this->_rule->getId());
}
return parent::_beforeSave();
}
示例14: _beforeSave
protected function _beforeSave()
{
$io = new Varien_Io_File();
$realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $this->getSitemapPath());
/**
* Check path is allow
*/
if (!$io->allowedPath($realPath, Mage::getBaseDir())) {
Mage::throwException(Mage::helper('sitemap')->__('Please define correct path'));
}
/**
* Check exists and writeable path
*/
if (!$io->fileExists($realPath, false)) {
Mage::throwException(Mage::helper('sitemap')->__('Please create the specified folder "%s" before saving the sitemap.', Mage::helper('core')->htmlEscape($this->getSitemapPath())));
}
if (!$io->isWriteable($realPath)) {
Mage::throwException(Mage::helper('sitemap')->__('Please make sure that "%s" is writable by web-server.', $this->getSitemapPath()));
}
/**
* Check allow filename
*/
if (!preg_match('#^[a-zA-Z0-9_\\.]+$#', $this->getSitemapFilename())) {
Mage::throwException(Mage::helper('sitemap')->__('Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'));
}
if (!preg_match('#\\.xml$#', $this->getSitemapFilename())) {
$this->setSitemapFilename($this->getSitemapFilename() . '.xml');
}
$this->setSitemapPath(rtrim(str_replace(str_replace('\\', '/', Mage::getBaseDir()), '', $realPath), '/') . '/');
return parent::_beforeSave();
}
示例15: _beforeSave
/**
* Processing object before save data
*
* @return Maverick_Crawler_Model_Crawler
*/
protected function _beforeSave()
{
if ($type = $this->getType()) {
Mage::dispatchEvent($type . '_save_before', $this->_getEventData());
}
return parent::_beforeSave();
}