Mage_Core_Model_Mysql4_Website Class Reference

Inheritance diagram for Mage_Core_Model_Mysql4_Website:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 getDefaultStoresSelect ($withDefault=false)

Protected Member Functions

 _construct ()
 _initUniqueFields ()
 _beforeSave (Mage_Core_Model_Abstract $object)
 _afterSave (Mage_Core_Model_Abstract $object)
 _afterDelete (Mage_Core_Model_Abstract $model)


Detailed Description

Definition at line 28 of file Website.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 87 of file Website.php.

00088     {
00089         $this->_getWriteAdapter()->delete(
00090             $this->getTable('core/config_data'),
00091             $this->_getWriteAdapter()->quoteInto("scope = 'websites' AND scope_id = ?", $model->getWebsiteId())
00092         );
00093         return $this;
00094     }

_afterSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions after object save

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_Core_Model_Mysql4_Website

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 70 of file Website.php.

00071     {
00072         if ($object->getIsDefault()) {
00073             $this->_getWriteAdapter()->update(
00074                 $this->getMainTable(),
00075                 array('is_default' => 0),
00076                 1
00077             );
00078             $this->_getWriteAdapter()->update(
00079                 $this->getMainTable(),
00080                 array('is_default' => 1),
00081                 $this->_getWriteAdapter()->quoteInto('website_id=?', $object->getId())
00082             );
00083         }
00084         return parent::_afterSave($object);
00085     }

_beforeSave ( Mage_Core_Model_Abstract object  )  [protected]

Perform actions before object save

Parameters:
Mage_Core_Model_Abstract $object
Returns:
Mage_Core_Model_Mysql4_Website

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 55 of file Website.php.

00056     {
00057         if(!preg_match('/^[a-z]+[a-z0-9_]*$/', $object->getCode())) {
00058             Mage::throwException(Mage::helper('core')->__('Website code should contain only letters (a-z), numbers (0-9) or underscore(_), first character should be a letter'));
00059         }
00060 
00061         return parent::_beforeSave($object);
00062     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 30 of file Website.php.

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

_initUniqueFields (  )  [protected]

Initialize unique fields

Returns:
Mage_Core_Model_Mysql4_Abstract

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 40 of file Website.php.

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

getDefaultStoresSelect ( withDefault = false  ) 

Retrieve default stores select object Select fields website_id, store_id

Parameters:
$withDefault include/exclude default admin website
Returns:
Varien_Db_Select

Definition at line 103 of file Website.php.

00103                                                                  {
00104         $select = $this->_getReadAdapter()->select()
00105             ->from(array('website_table' => $this->getTable('core/website')), array('website_id'))
00106             ->joinLeft(
00107                 array('store_group_table' => $this->getTable('core/store_group')),
00108                 '`website_table`.`website_id`=`store_group_table`.`website_id`'
00109                     . ' AND `website_table`.`default_group_id`=`store_group_table`.`group_id`',
00110                 array('store_id' => 'IFNULL(`store_group_table`.`default_store_id`, 0)')
00111             );
00112         if (!$withDefault) {
00113             $select->where('`website_table`.`website_id` <> ?', 0);
00114         }
00115         return $select;
00116     }


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