Mage_Adminhtml_Model_System_Store Class Reference

Inheritance diagram for Mage_Adminhtml_Model_System_Store:

Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getStoreValuesForForm ($empty=false, $all=false)
 getWebsiteValuesForForm ($empty=false, $all=false)
 getWebsiteOptionHash ($withDefault=false, $attribute= 'name')
 getStoreOptionHash ($withDefault=false, $attribute= 'name')
 getStoreGroupOptionHash ($attribute= 'name')
 getWebsiteName ($websiteId)
 getGroupName ($groupId)
 getStoreName ($storeId)
 getStoreData ($storeId)
 getStoreNameWithWebsite ($storeId)
 getWebsiteCollection ()
 getGroupCollection ()
 getStoreCollection ()
 reload ($type=null)
 getStoreNamePath ($storeId)
 setIsAdminScopeAllowed ($value)

Protected Member Functions

 _loadWebsiteCollection ()
 _loadGroupCollection ()
 _loadStoreCollection ()

Protected Attributes

 $_websiteCollection = array()
 $_groupCollection = array()
 $_storeCollection


Detailed Description

Definition at line 35 of file Store.php.


Constructor & Destructor Documentation

__construct (  ) 

Init model Load Website, Group and Store collections

Returns:
Mage_Adminhtml_Model_System_Store

Reimplemented from Varien_Object.

Definition at line 73 of file Store.php.

00074     {
00075         return $this->reload();
00076     }


Member Function Documentation

_loadGroupCollection (  )  [protected]

Load/Reload Group collection

Returns:
array

Definition at line 94 of file Store.php.

00095     {
00096         $this->_groupCollection = array();
00097         foreach (Mage::app()->getWebsites() as $website) {
00098             foreach ($website->getGroups() as $group) {
00099                 $this->_groupCollection[$group->getId()] = $group;
00100             }
00101         }
00102         return $this;
00103     }

_loadStoreCollection (  )  [protected]

Load/Reload Store collection

Returns:
array

Definition at line 110 of file Store.php.

00111     {
00112         $this->_storeCollection = Mage::app()->getStores();
00113         return $this;
00114     }

_loadWebsiteCollection (  )  [protected]

Load/Reload Website collection

Returns:
array

Definition at line 83 of file Store.php.

00084     {
00085         $this->_websiteCollection = Mage::app()->getWebsites();
00086         return $this;
00087     }

getGroupCollection (  ) 

Retrieve Group collection as array

Returns:
array

Definition at line 343 of file Store.php.

00344     {
00345         return $this->_groupCollection;
00346     }

getGroupName ( groupId  ) 

Retrieve Group name by Id

Parameters:
int groupId
Returns:
string

Definition at line 263 of file Store.php.

00264     {
00265         foreach ($this->_groupCollection as $group) {
00266             if ($group->getId() == $groupId) {
00267                 return $group->getName();
00268             }
00269         }
00270         return null;
00271     }

getStoreCollection (  ) 

Retrieve Store collection as array

Returns:
array

Definition at line 353 of file Store.php.

00354     {
00355         return $this->_storeCollection;
00356     }

getStoreData ( storeId  ) 

Retrieve store name with website and website store

Parameters:
int $storeId
Returns:
Mage_Core_Model_Store

Definition at line 293 of file Store.php.

00294     {
00295         if (isset($this->_storeCollection[$storeId])) {
00296             return $this->_storeCollection[$storeId];
00297         }
00298         return null;
00299     }

getStoreGroupOptionHash ( attribute = 'name'  ) 

Get store groups as id => name associative array

Parameters:
string $attribute
Returns:
array

Definition at line 233 of file Store.php.

00234     {
00235         foreach ($this->_groupCollection as $group) {
00236             $options[$group->getId()] = $group->getDataUsingMethod($attribute);
00237         }
00238         return $options;
00239     }

getStoreName ( storeId  ) 

Retrieve Store name by Id

Parameters:
int $storeId
Returns:
string

Definition at line 279 of file Store.php.

00280     {
00281         if (isset($this->_storeCollection[$storeId])) {
00282             return $this->_storeCollection[$storeId]->getName();
00283         }
00284         return null;
00285     }

getStoreNamePath ( storeId  ) 

Retrieve store path with website and website store

Parameters:
int $storeId
Returns:
string

Definition at line 396 of file Store.php.

00397     {
00398         $name = '';
00399         if (is_array($storeId)) {
00400             $names = array();
00401             foreach ($storeId as $id) {
00402                 $names[]= $this->getStoreNamePath($id);
00403             }
00404             $name = implode(', ', $names);
00405         }
00406         else {
00407             if (isset($this->_storeCollection[$storeId])) {
00408                 $data = $this->_storeCollection[$storeId];
00409                 $name .= $this->getWebsiteName($data->getWebsiteId());
00410                 $name .= ($name ? '/' : '').$this->getGroupName($data->getGroupId());
00411             }
00412         }
00413         return $name;
00414     }

getStoreNameWithWebsite ( storeId  ) 

Retrieve store name with website and website store

Parameters:
int $storeId
Returns:
string

Definition at line 307 of file Store.php.

00308     {
00309         $name = '';
00310         if (is_array($storeId)) {
00311             $names = array();
00312             foreach ($storeId as $id) {
00313                 $names[]= $this->getStoreNameWithWebsite($id);
00314             }
00315             $name = implode(', ', $names);
00316         }
00317         else {
00318             if (isset($this->_storeCollection[$storeId])) {
00319                 $data = $this->_storeCollection[$storeId];
00320                 $name .= $this->getWebsiteName($data->getWebsiteId());
00321                 $name .= ($name ? '/' : '').$this->getGroupName($data->getGroupId());
00322                 $name .= ($name ? '/' : '').$data->getName();
00323             }
00324         }
00325         return $name;
00326     }

getStoreOptionHash ( withDefault = false,
attribute = 'name' 
)

Get store views as id => name associative array

Parameters:
bool $withDefault
string $attribute
Returns:
array

Definition at line 218 of file Store.php.

00219     {
00220         $options = array();
00221         foreach (Mage::app()->getStores((bool)$withDefault && $this->_isAdminScopeAllowed) as $store) {
00222             $options[$store->getId()] = $store->getDataUsingMethod($attribute);
00223         }
00224         return $options;
00225     }

getStoreValuesForForm ( empty = false,
all = false 
)

Definition at line 116 of file Store.php.

00117     {
00118         $options = array();
00119         if ($empty) {
00120             $options[] = array(
00121                 'label' => '',
00122                 'value' => ''
00123             );
00124         }
00125         if ($all && $this->_isAdminScopeAllowed) {
00126             $options[] = array(
00127                 'label' => Mage::helper('adminhtml')->__('All Store Views'),
00128                 'value' => 0
00129             );
00130         }
00131 
00132         foreach ($this->_websiteCollection as $website) {
00133             $websiteShow = false;
00134             foreach ($this->_groupCollection as $group) {
00135                 if ($website->getId() != $group->getWebsiteId()) {
00136                     continue;
00137                 }
00138                 $groupShow = false;
00139                 foreach ($this->_storeCollection as $store) {
00140                     if ($group->getId() != $store->getGroupId()) {
00141                         continue;
00142                     }
00143                     if (!$websiteShow) {
00144                         $options[] = array(
00145                             'label' => $website->getName(),
00146                             'value' => array()
00147                         );
00148                         $websiteShow = true;
00149                     }
00150                     if (!$groupShow) {
00151                         $groupShow = true;
00152                         $values    = array();
00153                     }
00154                     $values[] = array(
00155                         'label' => '    ' . $store->getName(),
00156                         'value' => $store->getId()
00157                     );
00158                 }
00159                 if ($groupShow) {
00160                     $options[] = array(
00161                         'label' => '    ' . $group->getName(),
00162                         'value' => $values
00163                     );
00164                 }
00165             }
00166         }
00167         return $options;
00168     }

getWebsiteCollection (  ) 

Retrieve Website collection as array

Returns:
array

Definition at line 333 of file Store.php.

00334     {
00335         return $this->_websiteCollection;
00336     }

getWebsiteName ( websiteId  ) 

Retrieve Website name by Id

Parameters:
int websiteId
Returns:
string

Definition at line 247 of file Store.php.

00248     {
00249         foreach ($this->_websiteCollection as $website) {
00250             if ($website->getId() == $websiteId) {
00251                 return $website->getName();
00252             }
00253         }
00254         return null;
00255     }

getWebsiteOptionHash ( withDefault = false,
attribute = 'name' 
)

Get websites as id => name associative array

Parameters:
bool $withDefault
string $attribute
Returns:
array

Definition at line 202 of file Store.php.

00203     {
00204         $options = array();
00205         foreach (Mage::app()->getWebsites((bool)$withDefault && $this->_isAdminScopeAllowed) as $website) {
00206             $options[$website->getId()] = $website->getDataUsingMethod($attribute);
00207         }
00208         return $options;
00209     }

getWebsiteValuesForForm ( empty = false,
all = false 
)

Definition at line 170 of file Store.php.

00171     {
00172         $options = array();
00173         if ($empty) {
00174             $options[] = array(
00175                 'label' => '',
00176                 'value' => ''
00177             );
00178         }
00179         if ($all && $this->_isAdminScopeAllowed) {
00180             $options[] = array(
00181                 'label' => Mage::helper('adminhtml')->__('Admin'),
00182                 'value' => 0
00183             );
00184         }
00185 
00186         foreach ($this->_websiteCollection as $website) {
00187             $options[] = array(
00188                 'label' => $website->getName(),
00189                 'value' => $website->getId(),
00190             );
00191         }
00192         return $options;
00193     }

reload ( type = null  ) 

Load/Reload collection(s) by type Allowed types: website, group, store or null for all

Parameters:
string $type
Returns:
Mage_Adminhtml_Model_System_Store

Definition at line 365 of file Store.php.

00366     {
00367         if (is_null($type)) {
00368             $this->_loadWebsiteCollection();
00369             $this->_loadGroupCollection();
00370             $this->_loadStoreCollection();
00371         }
00372         else {
00373             switch ($type) {
00374                 case 'website':
00375                     $this->_loadWebsiteCollection();
00376                     break;
00377                 case 'group':
00378                     $this->_loadGroupCollection();
00379                     break;
00380                 case 'store':
00381                     $this->_loadStoreCollection();
00382                     break;
00383                 default:
00384                     break;
00385             }
00386         }
00387         return $this;
00388     }

setIsAdminScopeAllowed ( value  ) 

Specify whether to show admin-scope options

Parameters:
bool $value
Returns:
Mage_Adminhtml_Model_System_Store

Definition at line 422 of file Store.php.

00423     {
00424         $this->_isAdminScopeAllowed = (bool)$value;
00425         return $this;
00426     }


Member Data Documentation

$_groupCollection = array() [protected]

Definition at line 52 of file Store.php.

$_storeCollection [protected]

Definition at line 60 of file Store.php.

$_websiteCollection = array() [protected]

Definition at line 44 of file Store.php.


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

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