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


PHP Mage_Core_Model_Abstract::isDeleted方法代码示例

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


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

示例1: save

 /**
  *  Magento bug fix
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->_beforeSave($object);
     $this->_checkUnique($object);
     if (!is_null($object->getId())) {
         $condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
         /**
          * Not auto increment primary key support
          */
         if ($this->_isPkAutoIncrement) {
             $this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
         } else {
             $select = $this->_getWriteAdapter()->select()->from($this->getMainTable(), array($this->getIdFieldName()))->where($condition);
             if ($this->_getWriteAdapter()->fetchOne($select) !== false) {
                 $this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
             } else {
                 $this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object));
             }
         }
     } else {
         $this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object));
         $object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
     }
     $this->_afterSave($object);
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:32,代码来源:Abstract.php

示例2: save

 /**
  * Overwritten save method, updates data on duplicate key
  *
  * @param Mage_Core_Model_Abstract $object Data object
  * @return Aoe_TranslationLogger_Model_Resource_Translation_Logging
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->_serializeFields($object);
     $this->_beforeSave($object);
     $this->_getWriteAdapter()->insertIgnore($this->getMainTable(), $this->_prepareDataForSave($object));
     $this->unserializeFields($object);
     $this->_afterSave($object);
     return $this;
 }
开发者ID:zohmi,项目名称:Aoe_TranslationLogger,代码行数:18,代码来源:Logging.php

示例3: save

 /**
  * @param Aoe_Scheduler_Model_Job $object
  *
  * @return $this
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     if (!$object instanceof Aoe_Scheduler_Model_Job) {
         throw new InvalidArgumentException(sprintf("Expected object of type 'Aoe_Scheduler_Model_Job' got '%s'", get_class($object)));
     }
     if (!$object->getJobCode()) {
         Mage::throwException('Invalid data. Must have job code.');
     }
     $this->_serializeFields($object);
     $this->_beforeSave($object);
     $newValues = $this->getJobDataFromModel($object);
     $oldValues = $this->getJobDataFromDb($object->getJobCode());
     $defaultValues = $this->getJobDataFromXml($object->getJobCode());
     // Generate key/value lists for Update and Insert
     $updateValues = array_intersect_key($newValues, $oldValues);
     $insertValues = array_diff_key($newValues, $oldValues);
     // Remove Updates and Inserts that match defaults
     $updateValues = array_diff_assoc($updateValues, $defaultValues);
     $insertValues = array_diff_assoc($insertValues, $defaultValues);
     // Remove empty value inserts if this is a DB only job
     if (empty($defaultValues)) {
         foreach ($insertValues as $k => $v) {
             if ($v === '' || $v === null) {
                 unset($insertValues[$k]);
             }
         }
     }
     // Generate key/value lists for Delete (Old values, not being updated, that are identical to default values)
     $deleteValues = array_intersect_assoc(array_diff_key($oldValues, $updateValues), $defaultValues);
     $pathPrefix = $this->getJobPathPrefix($object->getJobCode()) . '/';
     $adapter = $this->_getWriteAdapter();
     foreach ($updateValues as $k => $v) {
         $adapter->update($this->getMainTable(), array('value' => $v), array('scope = ?' => 'default', 'scope_id = ?' => 0, 'path = ?' => $pathPrefix . $k));
     }
     foreach ($insertValues as $k => $v) {
         $adapter->insert($this->getMainTable(), array('scope' => 'default', 'scope_id' => 0, 'path' => $pathPrefix . $k, 'value' => $v));
     }
     foreach ($deleteValues as $k => $v) {
         $adapter->delete($this->getMainTable(), array('scope = ?' => 'default', 'scope_id = ?' => 0, 'path = ?' => $pathPrefix . $k));
     }
     if (count($updateValues) || count($insertValues) || count($deleteValues)) {
         Mage::getConfig()->reinit();
     }
     $this->unserializeFields($object);
     $this->_afterSave($object);
     return $this;
 }
开发者ID:unifiedarts,项目名称:Aoe_Scheduler,代码行数:55,代码来源:Job.php

示例4: save

 /**
  * Save Product Index data (forced save)
  *
  * @param Mage_Reports_Model_Product_Index_Abstract $object
  * @return Mage_Reports_Model_Resource_Product_Index_Abstract
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->_serializeFields($object);
     $this->_beforeSave($object);
     $this->_checkUnique($object);
     $data = $this->_prepareDataForSave($object);
     unset($data[$this->getIdFieldName()]);
     $matchFields = array('product_id', 'store_id');
     Mage::getResourceHelper('reports')->mergeVisitorProductIndex($this->getMainTable(), $data, $matchFields);
     $this->unserializeFields($object);
     $this->_afterSave($object);
     return $this;
 }
开发者ID:blazeriaz,项目名称:youguess,代码行数:22,代码来源:Abstract.php

示例5: save

 /**
  * Save object object data
  *
  * @param   Mage_Core_Model_Abstract $object
  * @return  Mage_Core_Model_Mysql4_Abstract
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->_beforeSave($object);
     $this->_checkUnique($object);
     if (!is_null($object->getId())) {
         $condition = $this->_getWriteAdapter()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
         $this->_getWriteAdapter()->update($this->getMainTable(), $this->_prepareDataForSave($object), $condition);
     } else {
         $this->_getWriteAdapter()->insert($this->getMainTable(), $this->_prepareDataForSave($object));
         $object->setId($this->_getWriteAdapter()->lastInsertId($this->getMainTable()));
     }
     $this->_afterSave($object);
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:23,代码来源:Abstract.php

示例6: save

 /**
  * Save object object data
  *
  * @param   Mage_Core_Model_Abstract $object
  * @return  Mage_Core_Model_Mysql4_Abstract
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $this->delete($object);
     }
     $this->_beforeSave($object);
     $this->_checkUnique($object);
     // create an API object for communication
     $apiobject = $this->createObject();
     if (!is_null($object->getId())) {
         // clone the data to the apiobject
         $data = $this->_prepareDataForSave($object);
         foreach ($data as $k => $v) {
             $apiobject->setField($k, $v);
         }
         // save using the API
         $apiobject->save();
     } else {
         // clone the data to the apiobject
         $data = $this->_prepareDataForSave($object);
         foreach ($data as $k => $v) {
             $apiobject->setField($k, $v);
         }
         // insert using the API
         $apiobject->add();
         // Clone the data from the api object to the Varien object
         $newfields = $apiobject->getFields();
         $data = array();
         foreach ($newfields as $newfield) {
             $data[$newfield->get(Pap_Api_Object::FIELD_NAME)] = $newfield->get(Pap_Api_Object::FIELD_VALUE);
         }
         $object->setData($data);
     }
     // TODO: What if there were errors? What do we do?
     // For the moment, we'll just log errors for debugging purposes.
     Mage::log($apiobject->getMessage());
     $this->_afterSave($object);
     return $this;
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:45,代码来源:Abstract.php

示例7: save

 /**
  * Save object
  *
  * @param Cm_Mongo_Model_Abstract|Mage_Core_Model_Abstract $object
  * @throws Mage_Core_Exception
  * @throws MongoCursorException
  * @return  Cm_Mongo_Model_Resource_Abstract
  */
 public function save(Mage_Core_Model_Abstract $object)
 {
     if ($object->isDeleted()) {
         return $object->delete();
     }
     $this->_beforeSave($object);
     $object->setLastUpdateStatus(NULL);
     // TRUE, do insert
     if ($object->isObjectNew()) {
         // Set created and updated timestamps
         $this->setTimestamps($object, $this->getEntitySchema()->created_timestamp, $this->getEntitySchema()->updated_timestamp);
         // Collect data for mongo
         $data = $this->dehydrate($object);
         $ops = $object->getPendingOperations();
         // Set autoincrement
         if (empty($data['_id']) && $this->getEntitySchema()->autoincrement) {
             $data['_id'] = $this->getAutoIncrement();
         }
         // Translate $set operations to simple insert data if possible
         if (isset($ops['$set'])) {
             foreach ($ops['$set'] as $key => $value) {
                 if (strpos($key, '.') === false) {
                     $data[$key] = $value;
                     unset($ops['$set'][$key]);
                 }
                 // @TODO - expand . delimited keys
             }
             if (!count($ops['$set'])) {
                 unset($ops['$set']);
             }
         }
         // Get insert options, merge default with instance-specific options
         $options = array('safe' => TRUE);
         if ($additionalSaveOptions = $object->getAdditionalSaveOptions()) {
             unset($additionalSaveOptions['upsert'], $additionalSaveOptions['multiple']);
             $options = array_merge($options, $additionalSaveOptions);
         }
         // Insert document (throws exception on failure)
         $this->_getWriteCollection()->insert($data, $options);
         if (!$object->hasData('_id') || $data['_id'] != $object->getData('_id')) {
             $object->setData('_id', $data['_id'])->setOrigData('_id', $data['_id']);
         }
         // Execute any pending operations
         if ($ops) {
             $object->setLastUpdateStatus($this->update($object, $ops));
         } else {
             if ($object->getAdditionalSaveCriteria()) {
                 $object->setAdditionalSaveCriteria();
                 $object->setLastUpdateStatus(TRUE);
             }
         }
     } else {
         if ($object->isObjectNew() === FALSE) {
             if (!$object->getId()) {
                 throw new Mage_Core_Exception('Cannot save existing object without id.');
             }
             // Set updated timestamp only
             $this->setTimestamps($object, FALSE, $this->getEntitySchema()->updated_timestamp);
             // Collect data for mongo and update using atomic operators
             $data = $this->getDataChangesForUpdate($object);
             $ops = $object->getPendingOperations();
             if (isset($ops['$set'])) {
                 $ops['$set'] = array_merge($data, (array) $ops['$set']);
             } else {
                 if ($data) {
                     $ops['$set'] = $data;
                 }
             }
             // Undo unsets that are overridden by sets
             if (isset($ops['$unset']) && isset($ops['$set'])) {
                 foreach ($ops['$unset'] as $key => $value) {
                     if (isset($ops['$set'][$key])) {
                         unset($ops['$unset'][$key]);
                     }
                 }
                 if (!count($ops['$unset'])) {
                     unset($ops['$unset']);
                 }
             }
             if ($ops) {
                 $object->setLastUpdateStatus($this->update($object, $ops));
             }
         } else {
             // Created timestamps not available on upsert
             $this->setTimestamps($object, FALSE, $this->getEntitySchema()->updated_timestamp);
             // Collect data for upsert. If no operations then use data, otherwise add data to $set operation
             $data = $this->dehydrate($object);
             if ($ops = $object->getPendingOperations()) {
                 if (isset($ops['$set'])) {
                     $ops['$set'] = array_merge($data, (array) $ops['$set']);
                 } else {
                     $ops['$set'] = $data;
//.........这里部分代码省略.........
开发者ID:walexer,项目名称:magento-mongo,代码行数:101,代码来源:Abstract.php


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