Mage_Core_Model_Mysql4_Store_Group Class Reference

Inheritance diagram for Mage_Core_Model_Mysql4_Store_Group:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Protected Member Functions

 _construct ()
 _afterSave (Mage_Core_Model_Abstract $model)
 _updateWebsiteDefaultGroup ($websiteId, $groupId)
 _changeWebsite (Mage_Core_Model_Abstract $model)
 _updateStoreWebsite ($groupId, $websiteId)
 _saveDefaultStore ($groupId, $storeId)


Detailed Description

Definition at line 35 of file Group.php.


Member Function Documentation

_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 42 of file Group.php.

00043     {
00044         $this->_updateStoreWebsite($model->getId(), $model->getWebsiteId());
00045         $this->_updateWebsiteDefaultGroup($model->getWebsiteId(), $model->getId());
00046         $this->_changeWebsite($model);
00047 
00048         return $this;
00049     }

_changeWebsite ( Mage_Core_Model_Abstract model  )  [protected]

Definition at line 67 of file Group.php.

00067                                                                        {
00068         if ($model->getOriginalWebsiteId() && $model->getWebsiteId() != $model->getOriginalWebsiteId()) {
00069             $write = $this->_getWriteAdapter();
00070             $groupId = $write->fetchOne($write->select()
00071                 ->from($this->getTable('core/website'), 'default_group_id')
00072                 ->where($write->quoteInto('website_id=?', $model->getOriginalWebsiteId())),
00073                 'default_group_id'
00074             );
00075             if ($groupId == $model->getId()) {
00076                 $write->update($this->getTable('core/website'),
00077                     array('default_group_id'=>0),
00078                     $write->quoteInto('website_id=?', $model->getOriginalWebsiteId()));
00079             }
00080         }
00081         return $this;
00082     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 37 of file Group.php.

00038     {
00039         $this->_init('core/store_group', 'group_id');
00040     }

_saveDefaultStore ( groupId,
storeId 
) [protected]

Definition at line 93 of file Group.php.

00094     {
00095         $write = $this->_getWriteAdapter();
00096         $bind = array('default_store_id'=>$storeId);
00097         $condition = $write->quoteInto('group_id=?', $groupId);
00098         $this->_getWriteAdapter()->update($this->getMainTable(), $bind, $condition);
00099         return $this;
00100     }

_updateStoreWebsite ( groupId,
websiteId 
) [protected]

Definition at line 84 of file Group.php.

00085     {
00086         $write = $this->_getWriteAdapter();
00087         $bind = array('website_id'=>$websiteId);
00088         $condition = $write->quoteInto('group_id=?', $groupId);
00089         $this->_getWriteAdapter()->update($this->getTable('core/store'), $bind, $condition);
00090         return $this;
00091     }

_updateWebsiteDefaultGroup ( websiteId,
groupId 
) [protected]

Definition at line 51 of file Group.php.

00052     {
00053         $write = $this->_getWriteAdapter();
00054         $cnt   = $write->fetchOne($write->select()
00055             ->from($this->getTable('core/store_group'), array('count'=>'COUNT(*)'))
00056             ->where($write->quoteInto('website_id=?', $websiteId)),
00057             'count');
00058         if ($cnt == 1) {
00059             $write->update($this->getTable('core/website'),
00060                 array('default_group_id' => $groupId),
00061                 $write->quoteInto('website_id=?', $websiteId)
00062             );
00063         }
00064         return $this;
00065     }


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