00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Core_Model_Mysql4_Website_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
00035 {
00036 protected $_loadDefault = false;
00037
00038 protected $_map = array('fields' => array('website_id' => 'main_table.website_id'));
00039
00040 protected function _construct()
00041 {
00042 $this->_init('core/website');
00043 }
00044
00045 public function addIdFilter($ids)
00046 {
00047 if (is_array($ids)) {
00048 if (empty($ids)) {
00049 $this->addFieldToFilter('website_id', null);
00050 }
00051 else {
00052 $this->addFieldToFilter('website_id', array('in'=>$ids));
00053 }
00054 }
00055 else {
00056 $this->addFieldToFilter('website_id', $ids);
00057 }
00058 return $this;
00059 }
00060
00061 public function setLoadDefault($loadDefault)
00062 {
00063 $this->_loadDefault = $loadDefault;
00064 return $this;
00065 }
00066
00067 public function getLoadDefault()
00068 {
00069 return $this->_loadDefault;
00070 }
00071
00072 public function toOptionArray()
00073 {
00074 return $this->_toOptionArray('website_id', 'name');
00075 }
00076
00077 public function toOptionHash()
00078 {
00079 return $this->_toOptionHash('website_id', 'name');
00080 }
00081
00082 public function load($printQuery = false, $logQuery = false)
00083 {
00084 if (!$this->getLoadDefault()) {
00085 $this->getSelect()->where($this->getConnection()->quoteInto('main_table.website_id>?', 0));
00086 }
00087 $this->unshiftOrder('main_table.name', 'ASC')
00088 ->unshiftOrder('main_table.sort_order', 'ASC')
00089 ;
00090 parent::load($printQuery, $logQuery);
00091 return $this;
00092 }
00093
00094 public function joinGroupAndStore()
00095 {
00096 $this->_idFieldName = 'website_group_store';
00097 $this->getSelect()->joinLeft(
00098 array('group_table' => $this->getTable('core/store_group')),
00099 'main_table.website_id=group_table.website_id',
00100 array('group_id'=>'group_id', 'group_title'=>'name')
00101 )->joinLeft(
00102 array('store_table' => $this->getTable('core/store')),
00103 'group_table.group_id=store_table.group_id',
00104 array('store_id'=>'store_id', 'store_title'=>'name')
00105 );
00106 $this->addOrder('group_table.name', 'ASC')
00107 ->addOrder('CASE WHEN store_table.store_id = 0 THEN 0 ELSE 1 END', 'ASC')
00108 ->addOrder('store_table.sort_order', 'ASC')
00109 ->addOrder('store_table.name', 'ASC')
00110 ;
00111 return $this;
00112 }
00113 }