Mage_Core_Model_Abstract Class Reference

Inheritance diagram for Mage_Core_Model_Abstract:

Varien_Object Mage_Admin_Model_Role Mage_Admin_Model_Roles Mage_Admin_Model_Rules Mage_Admin_Model_User Mage_AdminNotification_Model_Feed Mage_AdminNotification_Model_Inbox Mage_AmazonPayments_Model_Api_Debug Mage_Api_Model_Acl_Role Mage_Api_Model_Role Mage_Api_Model_Roles Mage_Api_Model_Rules Mage_Api_Model_User Mage_Bundle_Model_Option Mage_Bundle_Model_Price_Index Mage_Bundle_Model_Selection Mage_Catalog_Model_Abstract Mage_Catalog_Model_Design Mage_Catalog_Model_Product_Compare_Item Mage_Catalog_Model_Product_Flat_Indexer Mage_Catalog_Model_Product_Image Mage_Catalog_Model_Product_Link Mage_Catalog_Model_Product_Option Mage_Catalog_Model_Product_Option_Value Mage_Catalog_Model_Product_Status Mage_Catalog_Model_Product_Type_Configurable_Attribute Mage_Catalog_Model_Product_Website Mage_Catalog_Model_Sendfriend Mage_CatalogIndex_Model_Aggregation Mage_CatalogIndex_Model_Attribute Mage_CatalogIndex_Model_Data_Abstract Mage_CatalogIndex_Model_Indexer Mage_CatalogIndex_Model_Indexer_Abstract Mage_CatalogIndex_Model_Observer Mage_CatalogIndex_Model_Price Mage_CatalogIndex_Model_Retreiver Mage_CatalogInventory_Model_Stock Mage_CatalogInventory_Model_Stock_Item Mage_CatalogInventory_Model_Stock_Status Mage_CatalogRule_Model_Rule_Product_Price Mage_CatalogSearch_Model_Fulltext Mage_CatalogSearch_Model_Query Mage_Checkout_Model_Agreement Mage_Cms_Model_Block Mage_Cms_Model_Page Mage_Core_Model_Config_Data Mage_Core_Model_Convert_History Mage_Core_Model_Convert_Profile Mage_Core_Model_Design Mage_Core_Model_Flag Mage_Core_Model_Language Mage_Core_Model_Layout_Data Mage_Core_Model_Store Mage_Core_Model_Store_Group Mage_Core_Model_Translate_String Mage_Core_Model_Url_Rewrite Mage_Core_Model_Website Mage_Cron_Model_Schedule Mage_Customer_Model_Address_Abstract Mage_Customer_Model_Customer Mage_Customer_Model_Group Mage_Dataflow_Model_Batch Mage_Dataflow_Model_Batch_Abstract Mage_Dataflow_Model_Import Mage_Dataflow_Model_Profile Mage_Dataflow_Model_Profile_History Mage_Dataflow_Model_Session Mage_Directory_Model_Country Mage_Directory_Model_Country_Format Mage_Directory_Model_Currency Mage_Directory_Model_Region Mage_Downloadable_Model_Link Mage_Downloadable_Model_Link_Purchased Mage_Downloadable_Model_Link_Purchased_Item Mage_Downloadable_Model_Sample Mage_Eav_Model_Entity_Attribute_Abstract Mage_Eav_Model_Entity_Attribute_Group Mage_Eav_Model_Entity_Attribute_Option Mage_Eav_Model_Entity_Attribute_Set Mage_Eav_Model_Entity_Store Mage_Eav_Model_Entity_Type Mage_GiftMessage_Model_Message Mage_GiftRegistry_Model_Gift Mage_GoogleBase_Model_Attribute Mage_GoogleBase_Model_Item Mage_GoogleBase_Model_Type Mage_GoogleCheckout_Model_Api_Debug Mage_GoogleOptimizer_Model_Code Mage_Log_Model_Aggregation Mage_Log_Model_Cron Mage_Log_Model_Customer Mage_Log_Model_Log Mage_Log_Model_Visitor Mage_Log_Model_Visitor_Online Mage_Media_Model_Image Mage_Newsletter_Model_Problem Mage_Newsletter_Model_Queue Mage_Newsletter_Model_Template Mage_Paygate_Model_Authorizenet_Debug Mage_Payment_Model_Info Mage_Paypal_Model_Api_Debug Mage_PaypalUk_Model_Api_Debug Mage_Poll_Model_Poll Mage_Poll_Model_Poll_Answer Mage_Poll_Model_Poll_Vote Mage_ProductAlert_Model_Email Mage_ProductAlert_Model_Price Mage_ProductAlert_Model_Stock Mage_Rating_Model_Rating Mage_Rating_Model_Rating_Entity Mage_Rating_Model_Rating_Option_Vote Mage_Reports_Model_Event Mage_Reports_Model_Event_Type Mage_Reports_Model_Report Mage_Review_Model_Review Mage_Review_Model_Review_Summary Mage_Rule_Model_Rule Mage_Sales_Model_Abstract Mage_Sales_Model_Order_Creditmemo_Item Mage_Sales_Model_Order_Invoice_Item Mage_Sales_Model_Order_Item Mage_Sales_Model_Order_Pdf_Items_Abstract Mage_Sales_Model_Order_Shipment_Item Mage_Sales_Model_Order_Status Mage_Sales_Model_Order_Tax Mage_Sales_Model_Quote Mage_Sales_Model_Quote_Item_Abstract Mage_Sales_Model_Quote_Item_Option Mage_SalesRule_Model_Rule_Customer Mage_SalesRule_Model_Rule_Product Mage_SalesRule_Model_Validator Mage_Sendfriend_Model_Sendfriend Mage_Shipping_Model_Rate_Abstract Mage_Sitemap_Model_Sitemap Mage_Tag_Model_Tag Mage_Tag_Model_Tag_Relation Mage_Tax_Model_Calculation Mage_Tax_Model_Calculation_Rate Mage_Tax_Model_Calculation_Rate_Title Mage_Tax_Model_Calculation_Rule Mage_Tax_Model_Class Mage_Weee_Model_Observer Mage_Weee_Model_Tax Mage_Wishlist_Model_Item Mage_Wishlist_Model_Mysql4_Wishlist_Collection Mage_Wishlist_Model_Observer Mage_Wishlist_Model_Wishlist

List of all members.

Public Member Functions

 getIdFieldName ()
 getId ()
 setId ($id)
 getResourceName ()
 getResourceCollection ()
 getCollection ()
 load ($id, $field=null)
 afterLoad ()
 save ()
 delete ()
 getResource ()
 getEntityId ()

Protected Member Functions

 _init ($resourceModel)
 _setResourceModel ($resourceName, $resourceCollectionName=null)
 _getResource ()
 _afterLoad ()
 _beforeSave ()
 _afterSave ()
 _beforeDelete ()
 _protectFromNonAdmin ()
 _afterDelete ()

Protected Attributes

 $_eventPrefix = 'core_abstract'
 $_eventObject = 'object'
 $_resourceName
 $_resource
 $_resourceCollectionName
 $_cacheTag = false
 $_dataSaveAllowed = true


Detailed Description

Definition at line 35 of file Abstract.php.


Member Function Documentation

_afterDelete (  )  [protected]

Processing object after delete data

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Core_Model_Website, Mage_Dataflow_Model_Batch, Mage_Poll_Model_Poll_Answer, Mage_Tax_Model_Calculation_Rate, and Mage_Tax_Model_Calculation_Rule.

Definition at line 350 of file Abstract.php.

00351     {
00352         if ($this->_cacheTag) {
00353             if ($this->_cacheTag === true) {
00354                 $tags = array();
00355             }
00356             else {
00357                 $tags = array($this->_cacheTag);
00358             }
00359             Mage::app()->cleanCache($tags);
00360         }
00361         Mage::dispatchEvent('model_delete_after', array('object'=>$this));
00362         Mage::dispatchEvent($this->_eventPrefix.'_delete_after', array($this->_eventObject=>$this));
00363         return $this;
00364     }

_afterLoad (  )  [protected]

Processing object after load data

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Adminhtml_Model_System_Config_Backend_Encrypted, Mage_Adminhtml_Model_System_Config_Backend_Serialized, Mage_Catalog_Model_Product, Mage_Core_Model_Convert_Profile, Mage_Dataflow_Model_Profile, Mage_GoogleOptimizer_Model_Code_Page, Mage_GoogleOptimizer_Model_Code_Product, Mage_Rule_Model_Rule, and Mage_Sales_Model_Quote.

Definition at line 227 of file Abstract.php.

00228     {
00229         Mage::dispatchEvent('model_load_after', array('object'=>$this));
00230         Mage::dispatchEvent($this->_eventPrefix.'_load_after', array($this->_eventObject=>$this));
00231         return $this;
00232     }

_afterSave (  )  [protected]

Processing object after save data

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Adminhtml_Model_System_Config_Backend_Admin_Custom, Mage_Adminhtml_Model_System_Config_Backend_Admin_Usesecretkey, Mage_Adminhtml_Model_System_Config_Backend_Cache, Mage_Adminhtml_Model_System_Config_Backend_Catalog_Inventory_Managestock, Mage_Adminhtml_Model_System_Config_Backend_Catalog_Search_Type, Mage_Adminhtml_Model_System_Config_Backend_Category, Mage_Adminhtml_Model_System_Config_Backend_Currency_Allow, Mage_Adminhtml_Model_System_Config_Backend_Currency_Base, Mage_Adminhtml_Model_System_Config_Backend_Currency_Cron, Mage_Adminhtml_Model_System_Config_Backend_Currency_Default, Mage_Adminhtml_Model_System_Config_Backend_Datashare, Mage_Adminhtml_Model_System_Config_Backend_Layer_Children, Mage_Adminhtml_Model_System_Config_Backend_Locale, Mage_Adminhtml_Model_System_Config_Backend_Log_Cron, Mage_Adminhtml_Model_System_Config_Backend_Product_Alert_Cron, Mage_Adminhtml_Model_System_Config_Backend_Seo_Product, Mage_Adminhtml_Model_System_Config_Backend_Shipping_Tablerate, Mage_Adminhtml_Model_System_Config_Backend_Sitemap_Cron, Mage_Adminhtml_Model_System_Config_Backend_Store, Mage_Catalog_Model_Entity_Attribute, Mage_Catalog_Model_Product_Option, Mage_Catalog_Model_Product_Type_Configurable_Attribute, Mage_Catalog_Model_Product, Mage_CatalogInventory_Model_Stock_Item, Mage_CatalogRule_Model_Rule, Mage_Core_Model_Convert_Profile, Mage_Dataflow_Model_Profile, Mage_Downloadable_Model_Link, Mage_Downloadable_Model_Sample, Mage_Eav_Model_Entity_Attribute, Mage_Poll_Model_Poll_Answer, Mage_Sales_Model_Quote_Address, Mage_Sales_Model_Quote_Item, Mage_Sales_Model_Quote, Mage_Tax_Model_Calculation_Rate, and Mage_Tax_Model_Calculation_Rule.

Definition at line 280 of file Abstract.php.

00281     {
00282         if ($this->_cacheTag) {
00283             if ($this->_cacheTag === true) {
00284                 $tags = array();
00285             }
00286             else {
00287                 $tags = array($this->_cacheTag);
00288             }
00289             Mage::app()->cleanCache($tags);
00290         }
00291         Mage::dispatchEvent('model_save_after', array('object'=>$this));
00292         Mage::dispatchEvent($this->_eventPrefix.'_save_after', array($this->_eventObject=>$this));
00293         return $this;
00294     }

_beforeDelete (  )  [protected]

_beforeSave (  )  [protected]

Processing object before save data

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Adminhtml_Model_System_Config_Backend_Admin_Custom, Mage_Adminhtml_Model_System_Config_Backend_Admin_Usecustom, Mage_Adminhtml_Model_System_Config_Backend_Baseurl, Mage_Adminhtml_Model_System_Config_Backend_Design_Package, Mage_Adminhtml_Model_System_Config_Backend_Email_Address, Mage_Adminhtml_Model_System_Config_Backend_Email_Sender, Mage_Adminhtml_Model_System_Config_Backend_Encrypted, Mage_Adminhtml_Model_System_Config_Backend_Image, Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array, Mage_Adminhtml_Model_System_Config_Backend_Serialized, Mage_Adminhtml_Model_System_Config_Backend_Sitemap, Mage_Catalog_Model_Abstract, Mage_Catalog_Model_Entity_Attribute, Mage_Catalog_Model_Product, Mage_CatalogIndex_Model_Catalog_Index_Flag, Mage_CatalogInventory_Model_Stock_Item, Mage_Core_Model_Convert_History, Mage_Core_Model_Convert_Profile, Mage_Core_Model_Flag, Mage_Customer_Model_Address_Abstract, Mage_Customer_Model_Config_Share, Mage_Customer_Model_Customer, Mage_Dataflow_Model_Batch, Mage_Dataflow_Model_Profile_History, Mage_Dataflow_Model_Profile, Mage_Eav_Model_Entity_Attribute, Mage_GoogleOptimizer_Model_Code_Page, Mage_GoogleOptimizer_Model_Code_Product, Mage_Newsletter_Model_Template, Mage_Poll_Model_Poll_Vote, Mage_Reports_Model_Event, Mage_Rule_Model_Rule, Mage_Sales_Model_Order_Item, Mage_Sales_Model_Order_Shipment, Mage_Sales_Model_Order, Mage_Sales_Model_Quote_Address_Item, Mage_Sales_Model_Quote_Address_Rate, Mage_Sales_Model_Quote_Address, Mage_Sales_Model_Quote_Item_Abstract, Mage_Sales_Model_Quote_Item_Option, Mage_Sales_Model_Quote_Item, Mage_Sales_Model_Quote_Payment, Mage_Sales_Model_Quote, Mage_SalesRule_Model_Rule, Mage_Sitemap_Model_Sitemap, and Mage_Tax_Model_Calculation_Rate.

Definition at line 268 of file Abstract.php.

00269     {
00270         Mage::dispatchEvent('model_save_before', array('object'=>$this));
00271         Mage::dispatchEvent($this->_eventPrefix.'_save_before', array($this->_eventObject=>$this));
00272         return $this;
00273     }

_getResource (  )  [protected]

Get resource instance

Returns:
Mage_Core_Model_Mysql4_Abstract

Reimplemented in Mage_Bundle_Model_Price_Index, Mage_Catalog_Model_Product_Flat_Indexer, Mage_Catalog_Model_Product_Status, Mage_Catalog_Model_Product_Website, and Mage_Log_Model_Visitor_Online.

Definition at line 126 of file Abstract.php.

00127     {
00128         if (empty($this->_resourceName)) {
00129             Mage::throwException(Mage::helper('core')->__('Resource is not set'));
00130         }
00131 
00132         return Mage::getResourceSingleton($this->_resourceName);
00133     }

_init ( resourceModel  )  [protected]

Standard model initialization

Parameters:
string $resourceModel
string $idFieldName
Returns:
Mage_Core_Model_Abstract

Definition at line 99 of file Abstract.php.

00100     {
00101         $this->_setResourceModel($resourceModel);
00102     }

_protectFromNonAdmin (  )  [protected]

Safeguard func that will check, if we are in admin area

Exceptions:
Mage_Core_Exception 

Definition at line 335 of file Abstract.php.

00336     {
00337         if (Mage::registry('isSecureArea')) {
00338             return;
00339         }
00340         if (!Mage::app()->getStore()->isAdmin()) {
00341             Mage::throwException(Mage::helper('core')->__('Cannot complete this operation from non-admin area.'));
00342         }
00343     }

_setResourceModel ( resourceName,
resourceCollectionName = null 
) [protected]

Set resource names

If collection name is ommited, resource name will be used with _collection appended

Parameters:
string $resourceName
string|null $resourceCollectionName

Definition at line 112 of file Abstract.php.

00113     {
00114         $this->_resourceName = $resourceName;
00115         if (is_null($resourceCollectionName)) {
00116             $resourceCollectionName = $resourceName.'_collection';
00117         }
00118         $this->_resourceCollectionName = $resourceCollectionName;
00119     }

afterLoad (  ) 

Reimplemented in Mage_Core_Model_Config_Data, and Mage_Rule_Model_Rule.

Definition at line 234 of file Abstract.php.

00235     {
00236         $this->getResource()->afterLoad($this);
00237         $this->_afterLoad();
00238     }

delete (  ) 

Delete object from database

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Admin_Model_User, Mage_Api_Model_User, Mage_Catalog_Model_Product, and Mage_Customer_Model_Address.

Definition at line 301 of file Abstract.php.

00302     {
00303         $this->_getResource()->beginTransaction();
00304         try {
00305             $this->_beforeDelete();
00306             $this->_getResource()->delete($this);
00307             $this->_afterDelete();
00308 
00309             $this->_getResource()->commit();
00310         }
00311         catch (Exception $e){
00312             $this->_getResource()->rollBack();
00313             throw $e;
00314         }
00315         return $this;
00316     }

getCollection (  ) 

Reimplemented in Mage_Admin_Model_Rules, Mage_Admin_Model_User, Mage_Api_Model_Rules, and Mage_Api_Model_User.

Definition at line 203 of file Abstract.php.

00204     {
00205         return $this->getResourceCollection();
00206     }

getEntityId (  ) 

Definition at line 376 of file Abstract.php.

00377     {
00378         return $this->_getData('entity_id');
00379     }

getId (  ) 

Retrieve model object identifier

Returns:
mixed

Reimplemented from Varien_Object.

Reimplemented in Mage_Admin_Model_User, Mage_Api_Model_User, Mage_CatalogInventory_Model_Stock, and Mage_Core_Model_Store.

Definition at line 155 of file Abstract.php.

00156     {
00157         if ($fieldName = $this->getIdFieldName()) {
00158             return $this->_getData($fieldName);
00159         } else {
00160             return $this->_getData('id');
00161         }
00162     }

getIdFieldName (  ) 

Retrieve identifier field name for model

Returns:
string

Reimplemented from Varien_Object.

Definition at line 141 of file Abstract.php.

00142     {
00143         if (!($fieldName = parent::getIdFieldName())) {
00144             $fieldName = $this->_getResource()->getIdFieldName();
00145             $this->setIdFieldName($fieldName);
00146         }
00147         return $fieldName;
00148     }

getResource (  ) 

Retrieve model resource

Returns:
Mage_Core_Model_Mysql4_Abstract

Reimplemented in Mage_CatalogInventory_Model_Stock_Status, and Mage_Log_Model_Visitor.

Definition at line 371 of file Abstract.php.

00372     {
00373         return $this->_getResource();
00374     }

getResourceCollection (  ) 

Get collection instance

Returns:
object

Reimplemented in Mage_Catalog_Model_Abstract, Mage_Catalog_Model_Product, Mage_CatalogRule_Model_Rule, and Mage_SalesRule_Model_Rule.

Definition at line 195 of file Abstract.php.

00196     {
00197         if (empty($this->_resourceCollectionName)) {
00198             Mage::throwException(Mage::helper('core')->__('Model collection resource name is not defined'));
00199         }
00200         return Mage::getResourceModel($this->_resourceCollectionName, $this->_getResource());
00201     }

getResourceName (  ) 

Retrieve model resource name

Returns:
string

Definition at line 185 of file Abstract.php.

00186     {
00187         return $this->_resourceName;
00188     }

load ( id,
field = null 
)

Load object data

Parameters:
integer $id
Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Cms_Model_Page, Mage_Core_Model_Store, Mage_Core_Model_Website, Mage_Directory_Model_Currency, and Mage_Log_Model_Customer.

Definition at line 214 of file Abstract.php.

00215     {
00216         $this->_getResource()->load($this, $id, $field);
00217         $this->_afterLoad();
00218         $this->setOrigData();
00219         return $this;
00220     }

save (  ) 

Save object data

Returns:
Mage_Core_Model_Abstract

Reimplemented in Mage_Admin_Model_User, and Mage_Api_Model_User.

Definition at line 245 of file Abstract.php.

00246     {
00247         $this->_getResource()->beginTransaction();
00248         try {
00249             $this->_beforeSave();
00250             if ($this->_dataSaveAllowed) {
00251                 $this->_getResource()->save($this);
00252                 $this->_afterSave();
00253             }
00254             $this->_getResource()->commit();
00255         }
00256         catch (Exception $e){
00257             $this->_getResource()->rollBack();
00258             throw $e;
00259         }
00260         return $this;
00261     }

setId ( id  ) 

Declare model object identifier value

Parameters:
mixed $id
Returns:
Mage_Core_Model_Abstract

Reimplemented from Varien_Object.

Definition at line 170 of file Abstract.php.

00171     {
00172         if ($this->getIdFieldName()) {
00173             $this->setData($this->getIdFieldName(), $id);
00174         } else {
00175             $this->setData('id', $id);
00176         }
00177         return $this;
00178     }


Member Data Documentation

$_cacheTag = false [protected]

$_dataSaveAllowed = true [protected]

Definition at line 90 of file Abstract.php.

$_eventObject = 'object' [protected]

$_eventPrefix = 'core_abstract' [protected]

$_resource [protected]

Definition at line 65 of file Abstract.php.

$_resourceCollectionName [protected]

Definition at line 72 of file Abstract.php.

$_resourceName [protected]

Definition at line 58 of file Abstract.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:55 2009 for Magento by  doxygen 1.5.8