Mage_Core_Model_Store Class Reference

Inheritance diagram for Mage_Core_Model_Store:

Mage_Core_Model_Abstract Varien_Object

List of all members.

Public Member Functions

 load ($id, $field=null)
 loadConfig ($code)
 getCode ()
 getConfig ($path)
 initConfigCache ()
 setConfig ($path, $value)
 setWebsite (Mage_Core_Model_Website $website)
 getWebsite ()
 processSubst ($value)
 getDefaultBasePath ()
 getUrl ($route='', $params=array())
 getBaseUrl ($type=self::URL_TYPE_LINK, $secure=null)
 getId ()
 isAdmin ()
 isAdminUrlSecure ()
 isFrontUrlSecure ()
 isCurrentlySecure ()
 getBaseCurrencyCode ()
 getBaseCurrency ()
 getDefaultCurrencyCode ()
 getDefaultCurrency ()
 setCurrentCurrencyCode ($code)
 getCurrentCurrencyCode ()
 getAvailableCurrencyCodes ($skipBaseNotAllowed=false)
 getCurrentCurrency ()
 getCurrentCurrencyRate ()
 convertPrice ($price, $format=false, $includeContainer=true)
 roundPrice ($price)
 formatPrice ($price, $includeContainer=true)
 getPriceFilter ()
 getRootCategoryId ()
 setGroup ($group)
 getGroup ()
 getWebsiteId ()
 getGroupId ()
 getDefaultGroupId ()
 isCanDelete ()
 getCurrentUrl ($fromStore=true)
 getIsActive ()
 getName ()
 resetConfig ()
 isReadOnly ($value=null)

Public Attributes

const XML_PATH_STORE_IN_URL = 'web/url/use_store'
const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites'
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url'
const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend'
const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml'
const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'
const PRICE_SCOPE_GLOBAL = 0
const PRICE_SCOPE_WEBSITE = 1
const URL_TYPE_LINK = 'link'
const URL_TYPE_DIRECT_LINK = 'direct_link'
const URL_TYPE_WEB = 'web'
const URL_TYPE_SKIN = 'skin'
const URL_TYPE_JS = 'js'
const URL_TYPE_MEDIA = 'media'
const DEFAULT_CODE = 'default'
const ADMIN_CODE = 'admin'
const CACHE_TAG = 'store'

Protected Member Functions

 _construct ()
 _getSession ()
 _processConfigValue ($fullPath, $path, $node)
 _updatePathUseRewrites ($url)
 _updatePathUseStoreView ($url)
 _beforeDelete ()
 _afterDelte ()

Protected Attributes

 $_cacheTag = true
 $_eventPrefix = 'store'
 $_eventObject = 'store'
 $_priceFilter
 $_website
 $_group
 $_configCache = null
 $_configCacheBaseNodes = array()
 $_dirCache = array()
 $_urlCache = array()
 $_baseUrlCache = array()
 $_session
 $_isAdminSecure = null
 $_isFrontSecure = null


Detailed Description

Definition at line 35 of file Store.php.


Member Function Documentation

_afterDelte (  )  [protected]

rewrite in order to clear configuration cache

Returns:
Mage_Core_Model_Store

Definition at line 884 of file Store.php.

00885     {
00886         parent::_afterDelte();
00887         Mage::getConfig()->removeCache();
00888         return $this;
00889     }

_beforeDelete (  )  [protected]

Processing object before delete data

Returns:
Mage_Core_Model_Abstract

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 873 of file Store.php.

00874     {
00875         $this->_protectFromNonAdmin();
00876         return parent::_beforeDelete();
00877     }

_construct (  )  [protected]

Enter description here...

Reimplemented from Varien_Object.

Definition at line 107 of file Store.php.

00108     {
00109         $this->_init('core/store');
00110         $this->_configCacheBaseNodes = array(
00111             self::XML_PATH_PRICE_SCOPE,
00112             self::XML_PATH_SECURE_BASE_URL,
00113             self::XML_PATH_SECURE_IN_ADMINHTML,
00114             self::XML_PATH_SECURE_IN_FRONTEND,
00115             self::XML_PATH_STORE_IN_URL,
00116             self::XML_PATH_UNSECURE_BASE_URL,
00117             self::XML_PATH_USE_REWRITES,
00118             'web/unsecure/base_link_url',
00119             'web/secure/base_link_url',
00120             'general/locale/code'
00121         );
00122     }

_getSession (  )  [protected]

Retrieve store session object

Returns:
Mage_Core_Model_Session_Abstract

Definition at line 129 of file Store.php.

00130     {
00131         if (!$this->_session) {
00132             $this->_session = Mage::getModel('core/session')
00133                 ->init('store_'.$this->getCode());
00134         }
00135         return $this->_session;
00136     }

_processConfigValue ( fullPath,
path,
node 
) [protected]

Enter description here...

Parameters:
string $fullPath
string $path
Varien_Simplexml_Element $node
Returns:
string

Definition at line 308 of file Store.php.

00309     {
00310         if (isset($this->_configCache[$path])) {
00311             return $this->_configCache[$path];
00312         }
00313 
00314         if ($node->hasChildren()) {
00315             $aValue = array();
00316             foreach ($node->children() as $k=>$v) {
00317                 $aValue[$k] = $this->_processConfigValue($fullPath.'/'.$k, $path.'/'.$k, $v);
00318             }
00319             $this->_configCache[$path] = $aValue;
00320             return $aValue;
00321         }
00322 
00323         $sValue = (string)$node;
00324         if (!empty($node['backend_model']) && !empty($sValue)) {
00325             $backend = Mage::getModel((string)$node['backend_model']);
00326             $backend->setPath($path)->setValue($sValue)->afterLoad();
00327             $sValue = $backend->getValue();
00328         }
00329 
00330         if (is_string($sValue) && strpos($sValue, '{{')!==false) {
00331             if (strpos($sValue, '{{unsecure_base_url}}')!==false) {
00332                 $unsecureBaseUrl = $this->getConfig('web/unsecure/base_url');
00333                 $sValue = str_replace('{{unsecure_base_url}}', $unsecureBaseUrl, $sValue);
00334             } elseif (strpos($sValue, '{{secure_base_url}}')!==false) {
00335                 $secureBaseUrl = $this->getConfig('web/secure/base_url');
00336                 $sValue = str_replace('{{secure_base_url}}', $secureBaseUrl, $sValue);
00337             } else {
00338                 $sValue = Mage::getConfig()->substDistroServerVars($sValue);
00339             }
00340         }
00341 
00342         $this->_configCache[$path] = $sValue;
00343 
00344         return $sValue;
00345     }

_updatePathUseRewrites ( url  )  [protected]

Remove script file name from url in case when server rewrites are enabled

Parameters:
string $url
Returns:
string

Definition at line 441 of file Store.php.

00442     {
00443         if ($this->isAdmin()
00444             || !$this->getConfig(self::XML_PATH_USE_REWRITES)
00445             || !Mage::isInstalled()) {
00446             $url .= basename($_SERVER['SCRIPT_FILENAME']).'/';
00447         }
00448         return $url;
00449     }

_updatePathUseStoreView ( url  )  [protected]

Add store code to url in case if it is enabled in configuration

Parameters:
string $url
Returns:
string

Definition at line 457 of file Store.php.

00458     {
00459         if (Mage::isInstalled() && $this->getConfig(self::XML_PATH_STORE_IN_URL)) {
00460             $url .= $this->getCode().'/';
00461         }
00462         return $url;
00463     }

convertPrice ( price,
format = false,
includeContainer = true 
)

Convert price from default currency to current currency

Parameters:
double $price
boolean $format Format price to currency format
boolean $includeContainer Enclose into
Returns:
double

Definition at line 700 of file Store.php.

00701     {
00702         if ($this->getCurrentCurrency() && $this->getBaseCurrency()) {
00703             $value = $this->getBaseCurrency()->convert($price, $this->getCurrentCurrency());
00704         } else {
00705             $value = $price;
00706         }
00707         $value = $this->roundPrice($value);
00708 
00709         if ($this->getCurrentCurrency() && $format) {
00710             $value = $this->formatPrice($value, $includeContainer);
00711         }
00712         return $value;
00713     }

formatPrice ( price,
includeContainer = true 
)

Format price with currency filter (taking rate into consideration)

Parameters:
double $price
bool $includeContainer
Returns:
string

Definition at line 733 of file Store.php.

00734     {
00735         if ($this->getCurrentCurrency()) {
00736             return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
00737         }
00738         return $price;
00739     }

getAvailableCurrencyCodes ( skipBaseNotAllowed = false  ) 

Get allowed store currency codes

If base currency is not allowed in current website config scope, then it can be disabled with $skipBaseNotAllowed

Parameters:
bool $skipBaseNotAllowed
Returns:
array

Definition at line 638 of file Store.php.

00639     {
00640         $codes = $this->getData('available_currency_codes');
00641         if (is_null($codes)) {
00642             $codes = explode(',', $this->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_ALLOW));
00643             // add base currency, if it is not in allowed currencies
00644             $baseCurrencyCode = $this->getBaseCurrencyCode();
00645             if (!in_array($baseCurrencyCode, $codes)) {
00646                 $codes[] = $baseCurrencyCode;
00647 
00648                 // save base currency code index for further usage
00649                 $disallowedBaseCodeIndex = array_keys($codes);
00650                 $disallowedBaseCodeIndex = array_pop($disallowedBaseCodeIndex);
00651                 $this->setData('disallowed_base_currency_code_index', $disallowedBaseCodeIndex);
00652             }
00653             $this->setData('available_currency_codes', $codes);
00654         }
00655 
00656         // remove base currency code, if it is not allowed by config (optional)
00657         if ($skipBaseNotAllowed) {
00658             $disallowedBaseCodeIndex = $this->getData('disallowed_base_currency_code_index');
00659             if (null !== $disallowedBaseCodeIndex) {
00660                 unset($codes[$disallowedBaseCodeIndex]);
00661             }
00662         }
00663         return $codes;
00664     }

getBaseCurrency (  ) 

Retrieve store base currency

Returns:
Mage_Directory_Model_Currency

Definition at line 553 of file Store.php.

00554     {
00555         $currency = $this->getData('base_currency');
00556         if (is_null($currency)) {
00557             $currency = Mage::getModel('directory/currency')->load($this->getBaseCurrencyCode());
00558             $this->setData('base_currency', $currency);
00559         }
00560         return $currency;
00561     }

getBaseCurrencyCode (  ) 

Retrieve store base currency code

Returns:
string

Definition at line 539 of file Store.php.

00540     {
00541         if ($this->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE) == Mage_Core_Model_Store::PRICE_SCOPE_GLOBAL) {
00542             return Mage::app()->getBaseCurrencyCode();
00543         } else {
00544             return $this->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
00545         }
00546     }

getBaseUrl ( type = self::URL_TYPE_LINK,
secure = null 
)

Definition at line 395 of file Store.php.

00396     {
00397         $cacheKey = $type.'/'.(is_null($secure) ? 'null' : ($secure ? 'true' : 'false'));
00398         if (!isset($this->_baseUrlCache[$cacheKey])) {
00399             switch ($type) {
00400                 case self::URL_TYPE_WEB:
00401                     $secure = is_null($secure) ? $this->isCurrentlySecure() : (bool)$secure;
00402                     $url = $this->getConfig('web/'.($secure ? 'secure' : 'unsecure').'/base_url');
00403                     break;
00404 
00405                 case self::URL_TYPE_LINK:
00406                     $secure = (bool)$secure;
00407                     $url = $this->getConfig('web/'.($secure ? 'secure' : 'unsecure').'/base_link_url');
00408                     $url = $this->_updatePathUseRewrites($url);
00409                     $url = $this->_updatePathUseStoreView($url);
00410                     break;
00411 
00412                 case self::URL_TYPE_DIRECT_LINK:
00413                     $secure = (bool)$secure;
00414                     $url = $this->getConfig('web/'.($secure ? 'secure' : 'unsecure').'/base_link_url');
00415                     $url = $this->_updatePathUseRewrites($url);
00416                     break;
00417 
00418                 case self::URL_TYPE_SKIN:
00419                 case self::URL_TYPE_MEDIA:
00420                 case self::URL_TYPE_JS:
00421                     $secure = is_null($secure) ? $this->isCurrentlySecure() : (bool)$secure;
00422                     $url = $this->getConfig('web/'.($secure ? 'secure' : 'unsecure').'/base_'.$type.'_url');
00423                     break;
00424 
00425                 default:
00426                     throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid base url type'));
00427             }
00428 
00429             $this->_baseUrlCache[$cacheKey] = rtrim($url, '/').'/';
00430         }
00431 
00432         return $this->_baseUrlCache[$cacheKey];
00433     }

getCode (  ) 

Retrieve Store code

Returns:
string

Definition at line 186 of file Store.php.

00187     {
00188         return $this->_getData('code');
00189     }

getConfig ( path  ) 

Retrieve store configuration data

Parameters:
string $path
string $scope
Returns:
string|null

Definition at line 198 of file Store.php.

00199     {
00200         if (isset($this->_configCache[$path])) {
00201             return $this->_configCache[$path];
00202         }
00203 
00204         $config = Mage::getConfig();
00205 
00206         $fullPath = 'stores/'.$this->getCode().'/'.$path;
00207         $data = $config->getNode($fullPath);
00208         if (!$data && !Mage::isInstalled()) {
00209             $data = $config->getNode('default/' . $path);
00210         }
00211         if (!$data) {
00212             return null;
00213         }
00214         return $this->_processConfigValue($fullPath, $path, $data);
00215     }

getCurrentCurrency (  ) 

Retrieve store current currency

Returns:
Mage_Directory_Model_Currency

Definition at line 671 of file Store.php.

00672     {
00673         $currency = $this->getData('current_currency');
00674         if (is_null($currency)) {
00675             $currency = Mage::getModel('directory/currency')->load($this->getCurrentCurrencyCode());
00676             if ($this->getBaseCurrency()->getRate($currency)) {
00677                 $this->setData('current_currency', $currency);
00678             }
00679             else {
00680                 $this->setData('current_currency', $this->getBaseCurrency());
00681                 $this->setCurrentCurrencyCode($this->getBaseCurrency()->getCode());
00682             }
00683         }
00684         return $currency;
00685     }

getCurrentCurrencyCode (  ) 

Get current store currency code

Returns:
string

Definition at line 609 of file Store.php.

00610     {
00611         // try to get currently set code among allowed
00612         $code = $this->_getSession()->getCurrencyCode();
00613         if (empty($code)) {
00614             $code = $this->getDefaultCurrencyCode();
00615         }
00616         if (in_array($code, $this->getAvailableCurrencyCodes(true))) {
00617             return $code;
00618         }
00619 
00620         // take first one of allowed codes
00621         $codes = array_values($this->getAvailableCurrencyCodes(true));
00622         if (empty($codes)) {
00623             // return default code, if no codes specified at all
00624             return $this->getDefaultCurrencyCode();
00625         }
00626         return array_shift($codes);
00627     }

getCurrentCurrencyRate (  ) 

Definition at line 687 of file Store.php.

00688     {
00689         return $this->getBaseCurrency()->getRate($this->getCurrentCurrency());
00690     }

getCurrentUrl ( fromStore = true  ) 

Retrieve current url for store

Parameters:
bool|string $fromStore
Returns:
string

Definition at line 832 of file Store.php.

00833     {
00834         $query = Mage::getSingleton('core/url')->escape(ltrim(Mage::app()->getRequest()->getRequestString(), '/'));
00835 
00836         if (Mage::app()->getStore()->isCurrentlySecure()) {
00837             $parsedUrl = parse_url($this->getUrl('', array('_secure' => true)));
00838         } else {
00839             $parsedUrl = parse_url($this->getUrl(''));
00840         }
00841         $parsedQuery = array();
00842         if (isset($parsedUrl['query'])) {
00843             parse_str($parsedUrl['query'], $parsedQuery);
00844         }
00845 
00846         foreach (Mage::app()->getRequest()->getQuery() as $k => $v) {
00847             $parsedQuery[$k] = $v;
00848         }
00849 
00850         if (!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL, $this->getCode())) {
00851             $parsedQuery['___store'] = $this->getCode();
00852         }
00853         if ($fromStore !== false) {
00854             $parsedQuery['___from_store'] = $fromStore === true ? Mage::app()->getStore()->getCode() : $fromStore;
00855         }
00856 
00857         return $parsedUrl['scheme'] . '://' . $parsedUrl['host']
00858             . (isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '')
00859             . $parsedUrl['path'] . $query
00860             . ($parsedQuery ? '?'.http_build_query($parsedQuery, '', '&') : '');
00861     }

getDefaultBasePath (  ) 

Definition at line 373 of file Store.php.

00374     {
00375         if (!isset($_SERVER['SCRIPT_NAME'])) {
00376             return '/';
00377         }
00378         return rtrim(Mage::app()->getRequest()->getBasePath().'/').'/';
00379     }

getDefaultCurrency (  ) 

Retrieve store default currency

Returns:
Mage_Directory_Model_Currency

Definition at line 579 of file Store.php.

00580     {
00581         $currency = $this->getData('default_currency');
00582         if (is_null($currency)) {
00583             $currency = Mage::getModel('directory/currency')->load($this->getDefaultCurrencyCode());
00584             $this->setData('default_currency', $currency);
00585         }
00586         return $currency;
00587     }

getDefaultCurrencyCode (  ) 

Get default store currency code

Returns:
string

Definition at line 568 of file Store.php.

getDefaultGroupId (  ) 

Definition at line 812 of file Store.php.

00813     {
00814         return $this->_getData('default_group_id');
00815     }

getGroup (  ) 

Retrieve group model

Returns:
Mage_Core_Model_Store_Group

Definition at line 791 of file Store.php.

00792     {
00793         if (is_null($this->getGroupId())) {
00794             return false;
00795         }
00796         if (is_null($this->_group)) {
00797             $this->_group = Mage::getModel('core/store_group')->load($this->getGroupId());
00798         }
00799         return $this->_group;
00800     }

getGroupId (  ) 

Definition at line 807 of file Store.php.

00808     {
00809         return $this->_getData('group_id');
00810     }

getId (  ) 

Get store identifier

Returns:
int

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 470 of file Store.php.

00471     {
00472         return $this->_getData('store_id');
00473     }

getIsActive (  ) 

Definition at line 863 of file Store.php.

00864     {
00865         return $this->_getData('is_active');
00866     }

getName (  ) 

Definition at line 868 of file Store.php.

00869     {
00870         return $this->_getData('name');
00871     }

getPriceFilter (  ) 

Get store price filter

Returns:
Varien_Filter_Sprintf

Definition at line 746 of file Store.php.

00747     {
00748         if (!$this->_priceFilter) {
00749             if ($this->getBaseCurrency() && $this->getCurrentCurrency()) {
00750                 $this->_priceFilter = $this->getCurrentCurrency()->getFilter();
00751                 $this->_priceFilter->setRate($this->getBaseCurrency()->getRate($this->getCurrentCurrency()));
00752             }
00753             elseif($this->getDefaultCurrency()) {
00754                 $this->_priceFilter = $this->getDefaultCurrency()->getFilter();
00755             }
00756             else {
00757                 $this->_priceFilter = new Varien_Filter_Sprintf('%s', 2);
00758             }
00759         }
00760         return $this->_priceFilter;
00761     }

getRootCategoryId (  ) 

Enter description here...

Returns:
int

Definition at line 768 of file Store.php.

00769     {
00770         if (!$this->getGroup()) {
00771             return 0;
00772         }
00773         return $this->getGroup()->getRootCategoryId();
00774     }

getUrl ( route = '',
params = array() 
)

Retrieve url using store configuration specific

Parameters:
string $route
array $params
Returns:
string

Definition at line 388 of file Store.php.

00389     {
00390         $url = Mage::getModel('core/url')
00391             ->setStore($this);
00392         return $url->getUrl($route, $params);
00393     }

getWebsite (  ) 

Retrieve store website

Returns:
Mage_Core_Model_Website

Definition at line 289 of file Store.php.

00290     {
00291         if (is_null($this->getWebsiteId())) {
00292             return false;
00293         }
00294         if (is_null($this->_website)) {
00295             $this->_website = Mage::app()->getWebsite($this->getWebsiteId());
00296         }
00297         return $this->_website;
00298     }

getWebsiteId (  ) 

Definition at line 802 of file Store.php.

00803     {
00804         return $this->_getData('website_id');
00805     }

initConfigCache (  ) 

Initialize base store configuration data Method provide cache configuration data without loading store config XML

Returns:
Mage_Core_Model_Config

Funtionality related with config separation

Definition at line 223 of file Store.php.

00224     {
00225 //        return $this;
00226         /**
00227          * Funtionality related with config separation
00228          */
00229         if ($this->_configCache === null) {
00230             $code = $this->getCode();
00231             if ($code) {
00232                 if (Mage::app()->useCache('config')) {
00233                     $cacheId = 'store_' . $code . '_config_cache';
00234                     $data = Mage::app()->loadCache($cacheId);
00235                     if ($data) {
00236                         $data = unserialize($data);
00237                     } else {
00238                         $data = array();
00239                         foreach ($this->_configCacheBaseNodes as $node) {
00240                             $data[$node] = $this->getConfig($node);
00241                         }
00242                         Mage::app()->saveCache(
00243                             serialize($data),
00244                             $cacheId,
00245                             array(self::CACHE_TAG, Mage_Core_Model_Config::CACHE_TAG)
00246                         );
00247                     }
00248                     $this->_configCache = $data;
00249                 }
00250             }
00251         }
00252         return $this;
00253     }

isAdmin (  ) 

Check if store is admin store

Returns:
unknown

Definition at line 480 of file Store.php.

00481     {
00482         return $this->getId() == Mage_Core_Model_App::ADMIN_STORE_ID;
00483     }

isAdminUrlSecure (  ) 

Definition at line 486 of file Store.php.

00487     {
00488         if ($this->_isAdminSecure === null) {
00489             $this->_isAdminSecure = Mage::getStoreConfigFlag(
00490                Mage_Core_Model_Url::XML_PATH_SECURE_IN_ADMIN,
00491                $this->getId()
00492             );
00493         }
00494         return $this->_isAdminSecure;
00495     }

isCanDelete (  ) 

Definition at line 817 of file Store.php.

00818     {
00819         if (!$this->getId()) {
00820             return false;
00821         }
00822 
00823         return $this->getGroup()->getDefaultStoreId() != $this->getId();
00824     }

isCurrentlySecure (  ) 

Definition at line 508 of file Store.php.

00509     {
00510         if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
00511             return true;
00512         }
00513 
00514         if (Mage::isInstalled()) {
00515             $secureBaseUrl = Mage::getStoreConfig('web/secure/base_route_url');
00516             if (!$secureBaseUrl) {
00517                 return false;
00518             }
00519             $uri = Zend_Uri::factory($secureBaseUrl);
00520             $isSecure = ($uri->getScheme() == 'https' )
00521                 && isset($_SERVER['SERVER_PORT'])
00522                 && ($uri->getPort() == $_SERVER['SERVER_PORT']);
00523             return $isSecure;
00524         } else {
00525             $isSecure = isset($_SERVER['SERVER_PORT']) && (443 == $_SERVER['SERVER_PORT']);
00526             return $isSecure;
00527         }
00528     }

isFrontUrlSecure (  ) 

Definition at line 497 of file Store.php.

00498     {
00499         if ($this->_isFrontSecure === null) {
00500             $this->_isFrontSecure = Mage::getStoreConfigFlag(
00501                Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT,
00502                $this->getId()
00503             );
00504         }
00505         return $this->_isFrontSecure;
00506     }

isReadOnly ( value = null  ) 

Get/Set isReadOnly flag

Parameters:
bool $value
Returns:
bool

Definition at line 913 of file Store.php.

00914     {
00915         if (null !== $value) {
00916             $this->_isReadOnly = (bool)$value;
00917         }
00918         return $this->_isReadOnly;
00919     }

load ( id,
field = null 
)

Loading store data

Parameters:
mixed $id
string $field
Returns:
Mage_Core_Model_Store

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 145 of file Store.php.

00146     {
00147         if (!is_numeric($id) && is_null($field)) {
00148             $this->_getResource()->load($this, $id, 'code');
00149             return $this;
00150         }
00151         return parent::load($id, $field);
00152     }

loadConfig ( code  ) 

Loading store configuration data

Parameters:
string $code
Returns:
Mage_Core_Model_Store

Definition at line 160 of file Store.php.

00161     {
00162         if (is_numeric($code)) {
00163             foreach (Mage::getConfig()->getNode()->stores->children() as $storeCode=>$store) {
00164                 if ((int)$store->system->store->id==$code) {
00165                     $code = $storeCode;
00166                     break;
00167                 }
00168             }
00169         } else {
00170             $store = Mage::getConfig()->getNode()->stores->{$code};
00171         }
00172         if (!empty($store)) {
00173             $this->setCode($code);
00174             $id = (int)$store->system->store->id;
00175             $this->setId($id)->setStoreId($id);
00176             $this->setWebsiteId((int)$store->system->website->id);
00177         }
00178         return $this;
00179     }

processSubst ( value  ) 

Enter description here...

Todo:
check and delete this if it is not used anymore
Parameters:
string $value
Returns:
string

Definition at line 354 of file Store.php.

00355     {
00356         if (!is_string($value)) {
00357             return $value;
00358         }
00359 
00360         if (strpos($value, '{{unsecure_base_url}}')!==false) {
00361             $unsecureBaseUrl = $this->getConfig('web/unsecure/base_url');
00362             $value = str_replace('{{unsecure_base_url}}', $unsecureBaseUrl, $value);
00363 
00364         } elseif (strpos($value, '{{secure_base_url}}')!==false) {
00365             $secureBaseUrl = $this->getConfig('web/secure/base_url');
00366             $value = str_replace('{{secure_base_url}}', $secureBaseUrl, $value);
00367         } elseif (strpos($value, '{{')!==false) {
00368             $value = Mage::getConfig()->substDistroServerVars($value);
00369         }
00370         return $value;
00371     }

resetConfig (  ) 

Reinit and reset Config Data

Returns:
Mage_Core_Model_Store

Definition at line 896 of file Store.php.

00897     {
00898         Mage::getConfig()->reinit();
00899         $this->_dirCache        = array();
00900         $this->_configCache     = array();
00901         $this->_baseUrlCache    = array();
00902         $this->_urlCache        = array();
00903 
00904         return $this;
00905     }

roundPrice ( price  ) 

Round price

Parameters:
mixed $price
Returns:
double

Definition at line 721 of file Store.php.

00722     {
00723         return round($price, 2);
00724     }

setConfig ( path,
value 
)

Set config value for CURRENT model This value don't save in config

Parameters:
string $path
mixed $value
Returns:
Mage_Core_Model_Store

Definition at line 263 of file Store.php.

00264     {
00265         if (isset($this->_configCache[$path])) {
00266             $this->_configCache[$path] = $value;
00267         }
00268         $fullPath = 'stores/'.$this->getCode().'/'.$path;
00269         Mage::getConfig()->setNode($fullPath, $value);
00270 
00271         return $this;
00272     }

setCurrentCurrencyCode ( code  ) 

Set current store currency code

Parameters:
string $code
Returns:
string

Definition at line 595 of file Store.php.

00596     {
00597         $code = strtoupper($code);
00598         if (in_array($code, $this->getAvailableCurrencyCodes())) {
00599             $this->_getSession()->setCurrencyCode($code);
00600         }
00601         return $this;
00602     }

setGroup ( group  ) 

Set group model for store

Parameters:
Mage_Core_Model_Store_Group $group

Definition at line 781 of file Store.php.

00782     {
00783         $this->_group = $group;
00784     }

setWebsite ( Mage_Core_Model_Website website  ) 

Set website model

Parameters:
Mage_Core_Model_Website $website

Definition at line 279 of file Store.php.

00280     {
00281         $this->_website = $website;
00282     }


Member Data Documentation

$_baseUrlCache = array() [protected]

Definition at line 95 of file Store.php.

$_cacheTag = true [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 60 of file Store.php.

$_configCache = null [protected]

Definition at line 88 of file Store.php.

$_configCacheBaseNodes = array() [protected]

Definition at line 89 of file Store.php.

$_dirCache = array() [protected]

Definition at line 91 of file Store.php.

$_eventObject = 'store' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 70 of file Store.php.

$_eventPrefix = 'store' [protected]

Reimplemented from Mage_Core_Model_Abstract.

Definition at line 65 of file Store.php.

$_group [protected]

Definition at line 86 of file Store.php.

$_isAdminSecure = null [protected]

Definition at line 99 of file Store.php.

$_isFrontSecure = null [protected]

Definition at line 100 of file Store.php.

$_priceFilter [protected]

Definition at line 72 of file Store.php.

$_session [protected]

Definition at line 97 of file Store.php.

$_urlCache = array() [protected]

Definition at line 93 of file Store.php.

$_website [protected]

Definition at line 79 of file Store.php.

const ADMIN_CODE = 'admin'

Definition at line 56 of file Store.php.

const CACHE_TAG = 'store'

Definition at line 58 of file Store.php.

const DEFAULT_CODE = 'default'

Definition at line 55 of file Store.php.

const PRICE_SCOPE_GLOBAL = 0

Definition at line 45 of file Store.php.

Definition at line 46 of file Store.php.

const URL_TYPE_DIRECT_LINK = 'direct_link'

Definition at line 49 of file Store.php.

const URL_TYPE_JS = 'js'

Definition at line 52 of file Store.php.

const URL_TYPE_LINK = 'link'

Definition at line 48 of file Store.php.

const URL_TYPE_MEDIA = 'media'

Definition at line 53 of file Store.php.

const URL_TYPE_SKIN = 'skin'

Definition at line 51 of file Store.php.

const URL_TYPE_WEB = 'web'

Definition at line 50 of file Store.php.

const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'

Definition at line 44 of file Store.php.

const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url'

Definition at line 40 of file Store.php.

const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml'

Definition at line 42 of file Store.php.

const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend'

Definition at line 41 of file Store.php.

const XML_PATH_STORE_IN_URL = 'web/url/use_store'

Definition at line 37 of file Store.php.

const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url'

Definition at line 39 of file Store.php.

const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites'

Definition at line 38 of file Store.php.


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

Generated on Sat Jul 4 17:24:01 2009 for Magento by  doxygen 1.5.8