Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage
  • Mage_Adminhtml_Block_Html_Date
  • Mage_Adminhtml_Block_Html_Select
  • Mage_Api_Model_Wsdl_Config_Element
  • Mage_Captcha_Adminhtml_RefreshController
  • Mage_Captcha_RefreshController
  • Mage_Core_AjaxController
  • Mage_Core_Block_Abstract
  • Mage_Core_Block_Flush
  • Mage_Core_Block_Html_Calendar
  • Mage_Core_Block_Html_Date
  • Mage_Core_Block_Html_Link
  • Mage_Core_Block_Html_Select
  • Mage_Core_Block_Messages
  • Mage_Core_Block_Profiler
  • Mage_Core_Block_Store_Switcher
  • Mage_Core_Block_Template
  • Mage_Core_Block_Template_Facade
  • Mage_Core_Block_Template_Smarty
  • Mage_Core_Block_Template_Zend
  • Mage_Core_Block_Text
  • Mage_Core_Block_Text_List
  • Mage_Core_Block_Text_List_Item
  • Mage_Core_Block_Text_List_Link
  • Mage_Core_Block_Text_Tag
  • Mage_Core_Block_Text_Tag_Css
  • Mage_Core_Block_Text_Tag_Css_Admin
  • Mage_Core_Block_Text_Tag_Debug
  • Mage_Core_Block_Text_Tag_Js
  • Mage_Core_Block_Text_Tag_Meta
  • Mage_Core_Controller_Front_Action
  • Mage_Core_Controller_Front_Router
  • Mage_Core_Controller_Request_Http
  • Mage_Core_Controller_Response_Http
  • Mage_Core_Controller_Varien_Action
  • Mage_Core_Controller_Varien_Front
  • Mage_Core_Controller_Varien_Router_Abstract
  • Mage_Core_Controller_Varien_Router_Admin
  • Mage_Core_Controller_Varien_Router_Default
  • Mage_Core_Controller_Varien_Router_Standard
  • Mage_Core_Helper_Abstract
  • Mage_Core_Helper_Cookie
  • Mage_Core_Helper_Data
  • Mage_Core_Helper_File_Storage
  • Mage_Core_Helper_File_Storage_Database
  • Mage_Core_Helper_Hint
  • Mage_Core_Helper_Http
  • Mage_Core_Helper_Js
  • Mage_Core_Helper_String
  • Mage_Core_Helper_Translate
  • Mage_Core_Helper_Url
  • Mage_Core_Helper_Url_Rewrite
  • Mage_Core_IndexController
  • Mage_Core_Model_Abstract
  • Mage_Core_Model_App
  • Mage_Core_Model_App_Area
  • Mage_Core_Model_App_Emulation
  • Mage_Core_Model_Cache
  • Mage_Core_Model_Calculator
  • Mage_Core_Model_Config
  • Mage_Core_Model_Config_Base
  • Mage_Core_Model_Config_Data
  • Mage_Core_Model_Config_Element
  • Mage_Core_Model_Config_Options
  • Mage_Core_Model_Config_System
  • Mage_Core_Model_Cookie
  • Mage_Core_Model_Date
  • Mage_Core_Model_Design
  • Mage_Core_Model_Design_Package
  • Mage_Core_Model_Design_Source_Design
  • Mage_Core_Model_Email
  • Mage_Core_Model_Email_Info
  • Mage_Core_Model_Email_Template
  • Mage_Core_Model_Email_Template_Filter
  • Mage_Core_Model_Email_Template_Mailer
  • Mage_Core_Model_Email_Transport
  • Mage_Core_Model_Encryption
  • Mage_Core_Model_File_Storage
  • Mage_Core_Model_File_Storage_Abstract
  • Mage_Core_Model_File_Storage_Database
  • Mage_Core_Model_File_Storage_Database_Abstract
  • Mage_Core_Model_File_Storage_Directory_Database
  • Mage_Core_Model_File_Storage_File
  • Mage_Core_Model_File_Storage_Flag
  • Mage_Core_Model_File_Uploader
  • Mage_Core_Model_File_Validator_AvailablePath
  • Mage_Core_Model_File_Validator_NotProtectedExtension
  • Mage_Core_Model_Flag
  • Mage_Core_Model_Input_Filter
  • Mage_Core_Model_Input_Filter_MaliciousCode
  • Mage_Core_Model_Language
  • Mage_Core_Model_Layout
  • Mage_Core_Model_Layout_Data
  • Mage_Core_Model_Layout_Element
  • Mage_Core_Model_Layout_Update
  • Mage_Core_Model_Locale
  • Mage_Core_Model_Locale_Config
  • Mage_Core_Model_Log_Adapter
  • Mage_Core_Model_Magento_Api
  • Mage_Core_Model_Magento_Api_V2
  • Mage_Core_Model_Message
  • Mage_Core_Model_Message_Abstract
  • Mage_Core_Model_Message_Collection
  • Mage_Core_Model_Message_Error
  • Mage_Core_Model_Message_Notice
  • Mage_Core_Model_Message_Success
  • Mage_Core_Model_Message_Warning
  • Mage_Core_Model_Mysql4_Abstract
  • Mage_Core_Model_Mysql4_Cache
  • Mage_Core_Model_Mysql4_Collection_Abstract
  • Mage_Core_Model_Mysql4_Config
  • Mage_Core_Model_Mysql4_Config_Data
  • Mage_Core_Model_Mysql4_Config_Data_Collection
  • Mage_Core_Model_Mysql4_Design
  • Mage_Core_Model_Mysql4_Design_Collection
  • Mage_Core_Model_Mysql4_Design_Package_Collection
  • Mage_Core_Model_Mysql4_Design_Theme
  • Mage_Core_Model_Mysql4_Email_Template
  • Mage_Core_Model_Mysql4_Email_Template_Collection
  • Mage_Core_Model_Mysql4_File_Storage_Abstract
  • Mage_Core_Model_Mysql4_File_Storage_Database
  • Mage_Core_Model_Mysql4_File_Storage_Directory_Database
  • Mage_Core_Model_Mysql4_File_Storage_File
  • Mage_Core_Model_Mysql4_Flag
  • Mage_Core_Model_Mysql4_Language
  • Mage_Core_Model_Mysql4_Language_Collection
  • Mage_Core_Model_Mysql4_Layout
  • Mage_Core_Model_Mysql4_Resource
  • Mage_Core_Model_Mysql4_Session
  • Mage_Core_Model_Mysql4_Store
  • Mage_Core_Model_Mysql4_Store_Collection
  • Mage_Core_Model_Mysql4_Store_Group
  • Mage_Core_Model_Mysql4_Store_Group_Collection
  • Mage_Core_Model_Mysql4_Translate
  • Mage_Core_Model_Mysql4_Translate_String
  • Mage_Core_Model_Mysql4_Url_Rewrite
  • Mage_Core_Model_Mysql4_Url_Rewrite_Collection
  • Mage_Core_Model_Mysql4_Variable
  • Mage_Core_Model_Mysql4_Variable_Collection
  • Mage_Core_Model_Mysql4_Website
  • Mage_Core_Model_Mysql4_Website_Collection
  • Mage_Core_Model_Observer
  • Mage_Core_Model_Resource
  • Mage_Core_Model_Resource_Abstract
  • Mage_Core_Model_Resource_Cache
  • Mage_Core_Model_Resource_Config
  • Mage_Core_Model_Resource_Config_Data
  • Mage_Core_Model_Resource_Config_Data_Collection
  • Mage_Core_Model_Resource_Db_Abstract
  • Mage_Core_Model_Resource_Db_Collection_Abstract
  • Mage_Core_Model_Resource_Design
  • Mage_Core_Model_Resource_Design_Collection
  • Mage_Core_Model_Resource_Design_Package_Collection
  • Mage_Core_Model_Resource_Email_Template
  • Mage_Core_Model_Resource_Email_Template_Collection
  • Mage_Core_Model_Resource_Entity_Abstract
  • Mage_Core_Model_Resource_Entity_Table
  • Mage_Core_Model_Resource_File_Storage_Abstract
  • Mage_Core_Model_Resource_File_Storage_Database
  • Mage_Core_Model_Resource_File_Storage_Directory_Database
  • Mage_Core_Model_Resource_File_Storage_File
  • Mage_Core_Model_Resource_Flag
  • Mage_Core_Model_Resource_Helper_Abstract
  • Mage_Core_Model_Resource_Helper_Mysql4
  • Mage_Core_Model_Resource_Iterator
  • Mage_Core_Model_Resource_Language
  • Mage_Core_Model_Resource_Language_Collection
  • Mage_Core_Model_Resource_Layout
  • Mage_Core_Model_Resource_Resource
  • Mage_Core_Model_Resource_Session
  • Mage_Core_Model_Resource_Setup
  • Mage_Core_Model_Resource_Setup_Query_Modifier
  • Mage_Core_Model_Resource_Store
  • Mage_Core_Model_Resource_Store_Collection
  • Mage_Core_Model_Resource_Store_Group
  • Mage_Core_Model_Resource_Store_Group_Collection
  • Mage_Core_Model_Resource_Transaction
  • Mage_Core_Model_Resource_Translate
  • Mage_Core_Model_Resource_Translate_String
  • Mage_Core_Model_Resource_Type_Abstract
  • Mage_Core_Model_Resource_Type_Db
  • Mage_Core_Model_Resource_Type_Db_Mysqli
  • Mage_Core_Model_Resource_Type_Db_Mysqli_Setup
  • Mage_Core_Model_Resource_Type_Db_Pdo_Mysql
  • Mage_Core_Model_Resource_Url_Rewrite
  • Mage_Core_Model_Resource_Url_Rewrite_Collection
  • Mage_Core_Model_Resource_Variable
  • Mage_Core_Model_Resource_Variable_Collection
  • Mage_Core_Model_Resource_Website
  • Mage_Core_Model_Resource_Website_Collection
  • Mage_Core_Model_Session
  • Mage_Core_Model_Session_Abstract
  • Mage_Core_Model_Session_Abstract_Varien
  • Mage_Core_Model_Session_Abstract_Zend
  • Mage_Core_Model_Source_Email_Variables
  • Mage_Core_Model_Store
  • Mage_Core_Model_Store_Api
  • Mage_Core_Model_Store_Api_V2
  • Mage_Core_Model_Store_Group
  • Mage_Core_Model_Template
  • Mage_Core_Model_Translate
  • Mage_Core_Model_Translate_Expr
  • Mage_Core_Model_Translate_Inline
  • Mage_Core_Model_Translate_String
  • Mage_Core_Model_Url
  • Mage_Core_Model_Url_Rewrite
  • Mage_Core_Model_Url_Validator
  • Mage_Core_Model_Variable
  • Mage_Core_Model_Variable_Config
  • Mage_Core_Model_Variable_Observer
  • Mage_Core_Model_Website
  • Mage_Page_Block_Switch
  • Mage_Page_Block_Template_Container
  • Mage_Page_Block_Template_Links
  • Mage_Page_Block_Template_Links_Block
  • Mage_Sales_Model_Quote_Address_Total_Collector

Exceptions

  • Mage_Core_Controller_Varien_Exception
  • Mage_Core_Exception
  • Mage_Core_Model_Session_Exception
  • Mage_Core_Model_Store_Exception

Functions

  • destruct
  • is_dir_writeable
  • is_empty_date
  • mageCoreErrorHandler
  • mageDebugBacktrace
  • mageDelTree
  • mageFindClassFile
  • mageParseCsv
  • mageSendErrorFooter
  • mageSendErrorHeader
  • mageUndoMagicQuotes
  • now
  • sys_get_temp_dir
  • uc_words
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Core
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Abstract model class
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Core
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Core_Model_Abstract extends Varien_Object
 36: {
 37:     /**
 38:      * Prefix of model events names
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_eventPrefix = 'core_abstract';
 43: 
 44:     /**
 45:      * Parameter name in event
 46:      *
 47:      * In observe method you can use $observer->getEvent()->getObject() in this case
 48:      *
 49:      * @var string
 50:      */
 51:     protected $_eventObject = 'object';
 52: 
 53:     /**
 54:      * Name of the resource model
 55:      *
 56:      * @var string
 57:      */
 58:     protected $_resourceName;
 59: 
 60:     /**
 61:      * Resource model instance
 62:      *
 63:      * @var Mage_Core_Model_Mysql4_Abstract
 64:      */
 65:     protected $_resource;
 66: 
 67:     /**
 68:      * Name of the resource collection model
 69:      *
 70:      * @var string
 71:      */
 72:     protected $_resourceCollectionName;
 73: 
 74:     /**
 75:      * Model cache tag for clear cache in after save and after delete
 76:      *
 77:      * When you use true - all cache will be clean
 78:      *
 79:      * @var string || true
 80:      */
 81:     protected $_cacheTag    = false;
 82: 
 83:     /**
 84:      * Flag which can stop data saving after before save
 85:      * Can be used for next sequence: we check data in _beforeSave, if data are
 86:      * not valid - we can set this flag to false value and save process will be stopped
 87:      *
 88:      * @var bool
 89:      */
 90:     protected $_dataSaveAllowed = true;
 91: 
 92:     /**
 93:      * Flag which allow detect object state: is it new object (without id) or existing one (with id)
 94:      *
 95:      * @var bool
 96:      */
 97:     protected $_isObjectNew     = null;
 98: 
 99:     /**
100:      * Standard model initialization
101:      *
102:      * @param string $resourceModel
103:      * @param string $idFieldName
104:      * @return Mage_Core_Model_Abstract
105:      */
106:     protected function _init($resourceModel)
107:     {
108:         $this->_setResourceModel($resourceModel);
109:     }
110: 
111:     /**
112:      * Set resource names
113:      *
114:      * If collection name is ommited, resource name will be used with _collection appended
115:      *
116:      * @param string $resourceName
117:      * @param string|null $resourceCollectionName
118:      */
119:     protected function _setResourceModel($resourceName, $resourceCollectionName=null)
120:     {
121:         $this->_resourceName = $resourceName;
122:         if (is_null($resourceCollectionName)) {
123:             $resourceCollectionName = $resourceName.'_collection';
124:         }
125:         $this->_resourceCollectionName = $resourceCollectionName;
126:     }
127: 
128:     /**
129:      * Get resource instance
130:      *
131:      * @return Mage_Core_Model_Mysql4_Abstract
132:      */
133:     protected function _getResource()
134:     {
135:         if (empty($this->_resourceName)) {
136:             Mage::throwException(Mage::helper('core')->__('Resource is not set.'));
137:         }
138: 
139:         return Mage::getResourceSingleton($this->_resourceName);
140:     }
141: 
142: 
143:     /**
144:      * Retrieve identifier field name for model
145:      *
146:      * @return string
147:      */
148:     public function getIdFieldName()
149:     {
150:         if (!($fieldName = parent::getIdFieldName())) {
151:             $fieldName = $this->_getResource()->getIdFieldName();
152:             $this->setIdFieldName($fieldName);
153:         }
154:         return $fieldName;
155:     }
156: 
157:     /**
158:      * Retrieve model object identifier
159:      *
160:      * @return mixed
161:      */
162:     public function getId()
163:     {
164:         $fieldName = $this->getIdFieldName();
165:         if ($fieldName) {
166:             return $this->_getData($fieldName);
167:         } else {
168:             return $this->_getData('id');
169:         }
170:     }
171: 
172:     /**
173:      * Declare model object identifier value
174:      *
175:      * @param   mixed $id
176:      * @return  Mage_Core_Model_Abstract
177:      */
178:     public function setId($id)
179:     {
180:         if ($this->getIdFieldName()) {
181:             $this->setData($this->getIdFieldName(), $id);
182:         } else {
183:             $this->setData('id', $id);
184:         }
185:         return $this;
186:     }
187: 
188:     /**
189:      * Retrieve model resource name
190:      *
191:      * @return string
192:      */
193:     public function getResourceName()
194:     {
195:         return $this->_resourceName;
196:     }
197: 
198:     /**
199:      * Get collection instance
200:      *
201:      * @return object
202:      */
203:     public function getResourceCollection()
204:     {
205:         if (empty($this->_resourceCollectionName)) {
206:             Mage::throwException(Mage::helper('core')->__('Model collection resource name is not defined.'));
207:         }
208:         return Mage::getResourceModel($this->_resourceCollectionName, $this->_getResource());
209:     }
210: 
211:     public function getCollection()
212:     {
213:         return $this->getResourceCollection();
214:     }
215: 
216:     /**
217:      * Load object data
218:      *
219:      * @param   integer $id
220:      * @return  Mage_Core_Model_Abstract
221:      */
222:     public function load($id, $field=null)
223:     {
224:         $this->_beforeLoad($id, $field);
225:         $this->_getResource()->load($this, $id, $field);
226:         $this->_afterLoad();
227:         $this->setOrigData();
228:         $this->_hasDataChanges = false;
229:         return $this;
230:     }
231: 
232:     /**
233:      * Get array of objects transfered to default events processing
234:      *
235:      * @return array
236:      */
237:     protected function _getEventData()
238:     {
239:         return array(
240:             'data_object'       => $this,
241:             $this->_eventObject => $this,
242:         );
243:     }
244: 
245:     /**
246:      * Processing object before load data
247:      *
248:      * @return Mage_Core_Model_Abstract
249:      */
250:     protected function _beforeLoad($id, $field = null)
251:     {
252:         $params = array('object' => $this, 'field' => $field, 'value'=> $id);
253:         Mage::dispatchEvent('model_load_before', $params);
254:         $params = array_merge($params, $this->_getEventData());
255:         Mage::dispatchEvent($this->_eventPrefix.'_load_before', $params);
256:         return $this;
257:     }
258: 
259:     /**
260:      * Processing object after load data
261:      *
262:      * @return Mage_Core_Model_Abstract
263:      */
264:     protected function _afterLoad()
265:     {
266:         Mage::dispatchEvent('model_load_after', array('object'=>$this));
267:         Mage::dispatchEvent($this->_eventPrefix.'_load_after', $this->_getEventData());
268:         return $this;
269:     }
270: 
271: 
272: 
273:     /**
274:      * Object after load processing. Implemented as public interface for supporting objects after load in collections
275:      *
276:      * @return Mage_Core_Model_Abstract
277:      */
278:     public function afterLoad()
279:     {
280:         $this->getResource()->afterLoad($this);
281:         $this->_afterLoad();
282:         return $this;
283:     }
284: 
285:     /**
286:      * Check whether model has changed data.
287:      * Can be overloaded in child classes to perform advanced check whether model needs to be saved
288:      * e.g. usign resouceModel->hasDataChanged() or any other technique
289:      *
290:      * @return boolean
291:      */
292:     protected function _hasModelChanged()
293:     {
294:         return $this->hasDataChanges();
295:     }
296: 
297:     /**
298:      * Save object data
299:      *
300:      * @return Mage_Core_Model_Abstract
301:      */
302:     public function save()
303:     {
304:         /**
305:          * Direct deleted items to delete method
306:          */
307:         if ($this->isDeleted()) {
308:             return $this->delete();
309:         }
310:         if (!$this->_hasModelChanged()) {
311:             return $this;
312:         }
313:         $this->_getResource()->beginTransaction();
314:         $dataCommited = false;
315:         try {
316:             $this->_beforeSave();
317:             if ($this->_dataSaveAllowed) {
318:                 $this->_getResource()->save($this);
319:                 $this->_afterSave();
320:             }
321:             $this->_getResource()->addCommitCallback(array($this, 'afterCommitCallback'))
322:                 ->commit();
323:             $this->_hasDataChanges = false;
324:             $dataCommited = true;
325:         } catch (Exception $e) {
326:             $this->_getResource()->rollBack();
327:             $this->_hasDataChanges = true;
328:             throw $e;
329:         }
330:         if ($dataCommited) {
331:             $this->_afterSaveCommit();
332:         }
333:         return $this;
334:     }
335: 
336:     /**
337:      * Callback function which called after transaction commit in resource model
338:      *
339:      * @return Mage_Core_Model_Abstract
340:      */
341:     public function afterCommitCallback()
342:     {
343:         Mage::dispatchEvent('model_save_commit_after', array('object'=>$this));
344:         Mage::dispatchEvent($this->_eventPrefix.'_save_commit_after', $this->_getEventData());
345:         return $this;
346:     }
347: 
348:     /**
349:      * Processing data save after transaction commit.
350:      * When method is called we don't have garantee what transaction was really commited
351:      *
352:      * @deprecated after 1.4.0.0 - please use afterCommitCallback instead
353:      * @return Mage_Core_Model_Abstract
354:      */
355:     protected function _afterSaveCommit()
356:     {
357:         return $this;
358:     }
359: 
360:     /**
361:      * Check object state (true - if it is object without id on object just created)
362:      * This method can help detect if object just created in _afterSave method
363:      * problem is what in after save onject has id and we can't detect what object was
364:      * created in this transaction
365:      *
366:      * @param bool $flag
367:      * @return bool
368:      */
369:     public function isObjectNew($flag=null)
370:     {
371:         if ($flag !== null) {
372:             $this->_isObjectNew = $flag;
373:         }
374:         if ($this->_isObjectNew !== null) {
375:             return $this->_isObjectNew;
376:         }
377:         return !(bool)$this->getId();
378:     }
379: 
380:     /**
381:      * Processing object before save data
382:      *
383:      * @return Mage_Core_Model_Abstract
384:      */
385:     protected function _beforeSave()
386:     {
387:         if (!$this->getId()) {
388:             $this->isObjectNew(true);
389:         }
390:         Mage::dispatchEvent('model_save_before', array('object'=>$this));
391:         Mage::dispatchEvent($this->_eventPrefix.'_save_before', $this->_getEventData());
392:         return $this;
393:     }
394: 
395:     /**
396:      * Get list of cache tags applied to model object.
397:      * Return false if cache tags are not supported by model
398:      *
399:      * @return array | false
400:      */
401:     public function getCacheTags()
402:     {
403:         $tags = false;
404:         if ($this->_cacheTag) {
405:             if ($this->_cacheTag === true) {
406:                 $tags = array();
407:             } else {
408:                 if (is_array($this->_cacheTag)) {
409:                     $tags = $this->_cacheTag;
410:                 } else {
411:                     $tags = array($this->_cacheTag);
412:                 }
413:                 $idTags = $this->getCacheIdTags();
414:                 if ($idTags) {
415:                     $tags = array_merge($tags, $idTags);
416:                 }
417:             }
418:         }
419:         return $tags;
420:     }
421: 
422:     /**
423:      * Get cahce tags associated with object id
424:      *
425:      * @return array
426:      */
427:     public function getCacheIdTags()
428:     {
429:         $tags = false;
430:         if ($this->getId() && $this->_cacheTag) {
431:             $tags = array();
432:             if (is_array($this->_cacheTag)) {
433:                 foreach ($this->_cacheTag as $_tag) {
434:                     $tags[] = $_tag.'_'.$this->getId();
435:                 }
436:             } else {
437:                 $tags[] = $this->_cacheTag.'_'.$this->getId();
438:             }
439:         }
440:         return $tags;
441:     }
442: 
443:     /**
444:      * Remove model onject related cache
445:      *
446:      * @return Mage_Core_Model_Abstract
447:      */
448:     public function cleanModelCache()
449:     {
450:         $tags = $this->getCacheTags();
451:         if ($tags !== false) {
452:             Mage::app()->cleanCache($tags);
453:         }
454:         return $this;
455:     }
456: 
457:     /**
458:      * Processing object after save data
459:      *
460:      * @return Mage_Core_Model_Abstract
461:      */
462:     protected function _afterSave()
463:     {
464:         $this->cleanModelCache();
465:         Mage::dispatchEvent('model_save_after', array('object'=>$this));
466:         Mage::dispatchEvent($this->_eventPrefix.'_save_after', $this->_getEventData());
467:         return $this;
468:     }
469: 
470:     /**
471:      * Delete object from database
472:      *
473:      * @return Mage_Core_Model_Abstract
474:      */
475:     public function delete()
476:     {
477:         $this->_getResource()->beginTransaction();
478:         try {
479:             $this->_beforeDelete();
480:             $this->_getResource()->delete($this);
481:             $this->_afterDelete();
482: 
483:             $this->_getResource()->commit();
484:             $this->_afterDeleteCommit();
485:         }
486:         catch (Exception $e){
487:             $this->_getResource()->rollBack();
488:             throw $e;
489:         }
490:         return $this;
491:     }
492: 
493:     /**
494:      * Processing object before delete data
495:      *
496:      * @return Mage_Core_Model_Abstract
497:      */
498:     protected function _beforeDelete()
499:     {
500:         Mage::dispatchEvent('model_delete_before', array('object'=>$this));
501:         Mage::dispatchEvent($this->_eventPrefix.'_delete_before', $this->_getEventData());
502:         $this->cleanModelCache();
503:         return $this;
504:     }
505: 
506:     /**
507:      * Safeguard func that will check, if we are in admin area
508:      *
509:      * @throws Mage_Core_Exception
510:      */
511:     protected function _protectFromNonAdmin()
512:     {
513:         if (Mage::registry('isSecureArea')) {
514:             return;
515:         }
516:         if (!Mage::app()->getStore()->isAdmin()) {
517:             Mage::throwException(Mage::helper('core')->__('Cannot complete this operation from non-admin area.'));
518:         }
519:     }
520: 
521:     /**
522:      * Processing object after delete data
523:      *
524:      * @return Mage_Core_Model_Abstract
525:      */
526:     protected function _afterDelete()
527:     {
528:         Mage::dispatchEvent('model_delete_after', array('object'=>$this));
529:         Mage::dispatchEvent($this->_eventPrefix.'_delete_after', $this->_getEventData());
530:         return $this;
531:     }
532: 
533:     /**
534:      * Processing manipulation after main transaction commit
535:      *
536:      * @return Mage_Core_Model_Abstract
537:      */
538:     protected function _afterDeleteCommit()
539:     {
540:         Mage::dispatchEvent('model_delete_commit_after', array('object'=>$this));
541:         Mage::dispatchEvent($this->_eventPrefix.'_delete_commit_after', $this->_getEventData());
542:          return $this;
543:     }
544: 
545:     /**
546:      * Retrieve model resource
547:      *
548:      * @return Mage_Core_Model_Mysql4_Abstract
549:      */
550:     public function getResource()
551:     {
552:         return $this->_getResource();
553:     }
554: 
555:     public function getEntityId()
556:     {
557:         return $this->_getData('entity_id');
558:     }
559: 
560:     /**
561:      * Clearing object for correct deleting by garbage collector
562:      *
563:      * @return Mage_Core_Model_Abstract
564:      */
565:     final public function clearInstance()
566:     {
567:         $this->_clearReferences();
568:         Mage::dispatchEvent($this->_eventPrefix.'_clear', $this->_getEventData());
569:         $this->_clearData();
570:         return $this;
571:     }
572: 
573:     /**
574:      * Clearing cyclic references
575:      *
576:      * @return Mage_Core_Model_Abstract
577:      */
578:     protected function _clearReferences()
579:     {
580:         return $this;
581:     }
582: 
583:     /**
584:      * Clearing object's data
585:      *
586:      * @return Mage_Core_Model_Abstract
587:      */
588:     protected function _clearData()
589:     {
590:         return $this;
591:     }
592: 
593: }
594: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0