Mage_Core_Model_Mysql4_Store Class Reference

Inheritance diagram for Mage_Core_Model_Mysql4_Store:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Protected Member Functions

 _construct ()
 _initUniqueFields ()
 _beforeSave (Mage_Core_Model_Abstract $model)
 _afterSave (Mage_Core_Model_Abstract $object)
 _afterDelete (Mage_Core_Model_Abstract $model)
 _updateGroupDefaultStore ($groupId, $store_id)
 _changeGroup (Mage_Core_Model_Abstract $model)
 _getLoadSelect ($field, $value, $object)


Detailed Description

Definition at line 28 of file Store.php.


Member Function Documentation

_afterDelete ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object delete

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 68 of file Store.php.

00069     {
00070         $this->_getWriteAdapter()->delete(
00071             $this->getTable('core/config_data'),
00072             $this->_getWriteAdapter()->quoteInto("scope = 'stores' AND scope_id = ?", $model->getStoreId())
00073         );
00074         return $this;
00075     }

_afterSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 59 of file Store.php.

00060     {
00061         parent::_afterSave($object);
00062         $this->_updateGroupDefaultStore($object->getGroupId(), $object->getId());
00063         $this->_changeGroup($object);
00064 
00065         return $this;
00066     }

_beforeSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions before object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 49 of file Store.php.

00050     {
00051         if(!preg_match('/^[a-z]+[a-z0-9_]*$/',$model->getCode())) {
00052             Mage::throwException(
00053                 Mage::helper('core')->__('Store code should contain only letters (a-z), numbers (0-9) or underscore(_), first character should be a letter'));
00054         }
00055 
00056         return $this;
00057     }

_changeGroup ( Mage_Core_Model_Abstract model  )  [protected]

Definition at line 93 of file Store.php.

00093                                                                      {
00094         if ($model->getOriginalGroupId() && $model->getGroupId() != $model->getOriginalGroupId()) {
00095             $write = $this->_getWriteAdapter();
00096             $storeId = $write->fetchOne($write->select()
00097                 ->from($this->getTable('core/store_group'), 'default_store_id')
00098                 ->where($write->quoteInto('group_id=?', $model->getOriginalGroupId())),
00099                 'default_store_id'
00100             );
00101             if ($storeId == $model->getId()) {
00102                 $write->update($this->getTable('core/store_group'),
00103                     array('default_store_id'=>0),
00104                     $write->quoteInto('group_id=?', $model->getOriginalGroupId()));
00105             }
00106         }
00107         return $this;
00108     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 30 of file Store.php.

00031     {
00032         $this->_init('core/store', 'store_id');
00033     }

_getLoadSelect ( field,
value,
object 
) [protected]

Retrieve select object for load object data

Parameters:
string $field
mixed $value
Returns:
Zend_Db_Select

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 110 of file Store.php.

00111     {
00112         $select = $this->_getReadAdapter()->select()
00113             ->from($this->getMainTable())
00114             ->where($field.'=?', $value)
00115             ->order('sort_order ASC');
00116 
00117         return $select;
00118     }

_initUniqueFields (  )  [protected]

Initialize unique fields

Returns:
Mage_Core_Model_Mysql4_Abstract

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 40 of file Store.php.

00041     {
00042         $this->_uniqueFields = array(array(
00043             'field' => 'code',
00044             'title' => Mage::helper('core')->__('Store with the same code')
00045         ));
00046         return $this;
00047     }

_updateGroupDefaultStore ( groupId,
store_id 
) [protected]

Definition at line 77 of file Store.php.

00078     {
00079         $write = $this->_getWriteAdapter();
00080         $cnt   = $write->fetchOne($write->select()
00081             ->from($this->getTable('core/store'), array('count'=>'COUNT(*)'))
00082             ->where($write->quoteInto('group_id=?', $groupId)),
00083             'count');
00084         if ($cnt == 1) {
00085             $write->update($this->getTable('core/store_group'),
00086                 array('default_store_id' => $store_id),
00087                 $write->quoteInto('group_id=?', $groupId)
00088             );
00089         }
00090         return $this;
00091     }


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

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