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 |
Definition at line 35 of file Store.php.
__construct | ( | ) |
Init model Load Website, Group and Store collections
Reimplemented from Varien_Object.
Definition at line 73 of file Store.php.
00074 { 00075 return $this->reload(); 00076 }
_loadGroupCollection | ( | ) | [protected] |
Load/Reload Group collection
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] |
_loadWebsiteCollection | ( | ) | [protected] |
getGroupCollection | ( | ) |
getGroupName | ( | $ | groupId | ) |
getStoreCollection | ( | ) |
getStoreData | ( | $ | storeId | ) |
Retrieve store name with website and website store
int | $storeId |
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
string | $attribute |
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 | ) |
getStoreNamePath | ( | $ | storeId | ) |
Retrieve store path with website and website store
int | $storeId |
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
int | $storeId |
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
bool | $withDefault | |
string | $attribute |
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 | ( | ) |
getWebsiteName | ( | $ | websiteId | ) |
getWebsiteOptionHash | ( | $ | withDefault = false , |
|
$ | attribute = 'name' | |||
) |
Get websites as id => name associative array
bool | $withDefault | |
string | $attribute |
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
string | $type |
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 | ) |