Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Store.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Store\Model;
7 
14 use Magento\Framework\App\ScopeInterface as AppScopeInterface;
18 use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
21 use Zend\Uri\UriFactory;
22 
38 class Store extends AbstractExtensibleModel implements
39  AppScopeInterface,
40  UrlScopeInterface,
43 {
47  const STORE_ID = 'store_id';
48 
52  const ENTITY = 'store';
53 
57  const CUSTOM_ENTRY_POINT_PARAM = 'custom_entry_point';
58 
62  const XML_PATH_STORE_IN_URL = 'web/url/use_store';
63 
64  const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites';
65 
66  const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
67 
68  const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
69 
70  const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
71 
72  const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml';
73 
74  const XML_PATH_ENABLE_HSTS = 'web/secure/enable_hsts';
75 
76  const XML_PATH_ENABLE_UPGRADE_INSECURE = 'web/secure/enable_upgrade_insecure';
77 
78  const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
79 
80  const XML_PATH_UNSECURE_BASE_LINK_URL = 'web/unsecure/base_link_url';
81 
82  const XML_PATH_SECURE_BASE_STATIC_URL = 'web/secure/base_static_url';
83 
84  const XML_PATH_UNSECURE_BASE_STATIC_URL = 'web/unsecure/base_static_url';
85 
86  const XML_PATH_SECURE_BASE_MEDIA_URL = 'web/secure/base_media_url';
87 
88  const XML_PATH_UNSECURE_BASE_MEDIA_URL = 'web/unsecure/base_media_url';
89 
90  const XML_PATH_PRICE_SCOPE = 'catalog/price/scope';
91 
97  const PRICE_SCOPE_GLOBAL = 0;
98 
100 
103  const ADMIN_CODE = 'admin';
104 
108  const CACHE_TAG = 'store';
109 
113  const MEDIA_REWRITE_SCRIPT = 'get.php/';
114 
118  const BASE_URL_PLACEHOLDER = '{{base_url}}';
119 
124  const DEFAULT_STORE_ID = 0;
125 
129  const DISTRO_STORE_ID = 1;
130 
134  protected $_configCacheType;
135 
141  protected $_cacheTag = true;
142 
148  protected $_eventPrefix = 'store';
149 
155  protected $_eventObject = 'store';
156 
162  protected $_priceFilter;
163 
169  protected $_configCache = null;
170 
176  protected $_configCacheBaseNodes = [];
177 
183  protected $_dirCache = [];
184 
190  protected $_urlCache = [];
191 
197  protected $_baseUrlCache = [];
198 
204  protected $_session;
205 
212  protected $_isAdminSecure = null;
213 
219  protected $_isFrontSecure = null;
220 
226  protected $_frontendName = null;
227 
233  private $_isReadOnly = false;
234 
240  protected $_url;
241 
245  protected $_isCustomEntryPoint = false;
246 
250  protected $_request;
251 
256 
262  protected $_coreFileStorageDatabase = null;
263 
269  protected $filesystem;
270 
276  protected $_config;
277 
281  protected $_sidResolver;
282 
287 
291  protected $_httpContext;
292 
296  protected $currencyFactory;
297 
301  protected $groupRepository;
302 
307 
311  protected $information;
312 
316  private $_storeManager;
317 
321  private $urlModifier;
322 
326  private $eventManager;
327 
357  public function __construct(
358  \Magento\Framework\Model\Context $context,
359  \Magento\Framework\Registry $registry,
360  \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
361  \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
363  \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
364  \Magento\Framework\App\Cache\Type\Config $configCacheType,
365  \Magento\Framework\UrlInterface $url,
366  \Magento\Framework\App\RequestInterface $request,
367  \Magento\Config\Model\ResourceModel\Config\Data $configDataResource,
368  \Magento\Framework\Filesystem $filesystem,
371  \Magento\Framework\Session\SidResolverInterface $sidResolver,
372  \Magento\Framework\App\Http\Context $httpContext,
373  \Magento\Framework\Session\SessionManagerInterface $session,
374  \Magento\Directory\Model\CurrencyFactory $currencyFactory,
376  $currencyInstalled,
377  \Magento\Store\Api\GroupRepositoryInterface $groupRepository,
378  \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository,
379  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
380  $isCustomEntryPoint = false,
381  array $data = [],
382  \Magento\Framework\Event\ManagerInterface $eventManager = null
383  ) {
384  $this->_coreFileStorageDatabase = $coreFileStorageDatabase;
385  $this->_config = $config;
386  $this->_url = $url;
387  $this->_configCacheType = $configCacheType;
388  $this->_request = $request;
389  $this->_configDataResource = $configDataResource;
390  $this->_isCustomEntryPoint = $isCustomEntryPoint;
391  $this->filesystem = $filesystem;
392  $this->_storeManager = $storeManager;
393  $this->_sidResolver = $sidResolver;
394  $this->_httpContext = $httpContext;
395  $this->_session = $session;
396  $this->currencyFactory = $currencyFactory;
397  $this->information = $information;
398  $this->_currencyInstalled = $currencyInstalled;
399  $this->groupRepository = $groupRepository;
400  $this->websiteRepository = $websiteRepository;
401  $this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance()
402  ->get(\Magento\Framework\Event\ManagerInterface::class);
403  parent::__construct(
404  $context,
405  $registry,
406  $extensionFactory,
408  $resource,
409  $resourceCollection,
410  $data
411  );
412  }
413 
417  public function __sleep()
418  {
420  $properties = array_diff($properties, ['_coreFileStorageDatabase', '_config']);
421  return $properties;
422  }
423 
429  public function __wakeup()
430  {
432  $this->_coreFileStorageDatabase = ObjectManager::getInstance()
433  ->get(\Magento\MediaStorage\Helper\File\Storage\Database::class);
434  $this->_config = ObjectManager::getInstance()->get(
435  \Magento\Framework\App\Config\ReinitableConfigInterface::class
436  );
437  }
438 
444  protected function _construct()
445  {
446  $this->_init(\Magento\Store\Model\ResourceModel\Store::class);
447  }
448 
454  protected function _getSession()
455  {
456  if (!$this->_session->isSessionExists()) {
457  $this->_session->setName('store_' . $this->getCode());
458  $this->_session->start();
459  }
460  return $this->_session;
461  }
462 
468  protected function _getValidationRulesBeforeSave()
469  {
470  $validator = new \Magento\Framework\Validator\DataObject();
471 
472  $storeLabelRule = new \Zend_Validate_NotEmpty();
473  $storeLabelRule->setMessage(__('Name is required'), \Zend_Validate_NotEmpty::IS_EMPTY);
474  $validator->addRule($storeLabelRule, 'name');
475 
476  $storeCodeRule = new \Zend_Validate_Regex('/^[a-z]+[a-z0-9_]*$/i');
477  $storeCodeRule->setMessage(
478  __(
479  'The store code may contain only letters (a-z), numbers (0-9) or underscore (_),'
480  . ' and the first character must be a letter.'
481  ),
483  );
484  $validator->addRule($storeCodeRule, 'code');
485 
486  return $validator;
487  }
488 
496  public function load($key, $field = null)
497  {
498  if (!is_numeric($key) && $field === null) {
499  $this->_getResource()->load($this, $key, 'code');
500  return $this;
501  }
502  return parent::load($key, $field);
503  }
504 
510  public function getCode()
511  {
512  return $this->_getData('code');
513  }
514 
518  public function setCode($code)
519  {
520  return $this->setData('code', $code);
521  }
522 
526  public function getName()
527  {
528  return $this->_getData('name');
529  }
530 
534  public function setName($name)
535  {
536  return $this->setData('name', $name);
537  }
538 
545  public function getConfig($path)
546  {
547  $data = $this->_config->getValue($path, ScopeInterface::SCOPE_STORE, $this->getCode());
548  if ($data === null) {
549  $data = $this->_config->getValue($path);
550  }
551  return $data === false ? null : $data;
552  }
553 
560  public function setWebsite(Website $website)
561  {
562  $this->setWebsiteId($website->getId());
563  }
564 
570  public function getWebsite()
571  {
572  if ($this->getWebsiteId() === null) {
573  return false;
574  }
575  return $this->websiteRepository->getById($this->getWebsiteId());
576  }
577 
585  public function getUrl($route = '', $params = [])
586  {
588  $url = $this->_url->setScope($this);
589  if ($this->_storeManager->getStore()->getId() != $this->getId()) {
590  $params['_scope_to_url'] = true;
591  }
592 
593  return $url->getUrl($route, $params);
594  }
595 
607  public function getBaseUrl($type = UrlInterface::URL_TYPE_LINK, $secure = null)
608  {
609  $cacheKey = $type . '/' . ($secure === null ? 'null' : ($secure ? 'true' : 'false'));
610  if (!isset($this->_baseUrlCache[$cacheKey])) {
611  $secure = $secure === null ? $this->isCurrentlySecure() : (bool)$secure;
612  switch ($type) {
614  $path = $secure
617  $url = $this->getConfig($path);
618  break;
619 
622  $url = $this->getConfig($path);
623  $url = $this->_updatePathUseRewrites($url);
625  break;
626 
629  $url = $this->getConfig($path);
630  $url = $this->_updatePathUseRewrites($url);
631  break;
632 
635  $url = $this->getConfig($path);
636  if (!$url) {
637  $url = $this->getBaseUrl(UrlInterface::URL_TYPE_WEB, $secure)
638  . $this->filesystem->getUri(DirectoryList::STATIC_VIEW);
639  }
640  break;
641 
643  $url = $this->_getMediaScriptUrl($this->filesystem, $secure);
644  if (!$url) {
646  $url = $this->getConfig($path);
647  if (!$url) {
648  $url = $this->getBaseUrl(UrlInterface::URL_TYPE_WEB, $secure)
649  . $this->filesystem->getUri(DirectoryList::MEDIA);
650  }
651  }
652  break;
653 
654  default:
655  throw new \InvalidArgumentException('Invalid base url type');
656  }
657 
658  if (false !== strpos($url, self::BASE_URL_PLACEHOLDER)) {
659  $url = str_replace(self::BASE_URL_PLACEHOLDER, $this->_request->getDistroBaseUrl(), $url);
660  }
661 
662  $this->_baseUrlCache[$cacheKey] = $this->getUrlModifier()->execute(
663  rtrim($url, '/') . '/',
664  \Magento\Framework\Url\ModifierInterface::MODE_BASE
665  );
666  }
667 
668  return $this->_baseUrlCache[$cacheKey];
669  }
670 
676  public function getBaseMediaDir()
677  {
678  return $this->filesystem->getUri(DirectoryList::MEDIA);
679  }
680 
686  public function getBaseStaticDir()
687  {
688  return $this->filesystem->getUri(DirectoryList::STATIC_VIEW);
689  }
690 
697  protected function _updatePathUseRewrites($url)
698  {
699  if ($this->getForceDisableRewrites() || !$this->getConfig(self::XML_PATH_USE_REWRITES)) {
700  if ($this->_isCustomEntryPoint()) {
701  $indexFileName = 'index.php';
702  } else {
703  $indexFileName = basename($_SERVER['SCRIPT_FILENAME']);
704  }
705  $url .= $indexFileName . '/';
706  }
707  return $url;
708  }
709 
715  protected function _isCustomEntryPoint()
716  {
718  }
719 
730  protected function _getMediaScriptUrl(Filesystem $filesystem, $secure)
731  {
732  if (!$this->getConfig(self::XML_PATH_USE_REWRITES) && $this->_coreFileStorageDatabase->checkDbUsage()) {
733  $baseUrl = $this->getBaseUrl(UrlInterface::URL_TYPE_WEB, $secure);
734  return $baseUrl . $filesystem->getUri(DirectoryList::PUB) . '/' . self::MEDIA_REWRITE_SCRIPT;
735  }
736  return false;
737  }
738 
745  protected function _updatePathUseStoreView($url)
746  {
747  if ($this->isUseStoreInUrl()) {
748  $url .= $this->getCode() . '/';
749  }
750  return $url;
751  }
752 
758  public function isUseStoreInUrl()
759  {
760  return !($this->hasDisableStoreInUrl() && $this->getDisableStoreInUrl())
761  && $this->getConfig(self::XML_PATH_STORE_IN_URL);
762  }
763 
769  public function getId()
770  {
771  return $this->_getData(self::STORE_ID);
772  }
773 
779  public function isFrontUrlSecure()
780  {
781  if ($this->_isFrontSecure === null) {
782  $this->_isFrontSecure = $this->_config
783  ->isSetFlag(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE, $this->getId());
784  }
785  return $this->_isFrontSecure;
786  }
787 
791  public function isUrlSecure()
792  {
793  return $this->isFrontUrlSecure();
794  }
795 
801  public function isCurrentlySecure()
802  {
803  if ($this->_request->isSecure()) {
804  return true;
805  }
806 
807  $secureBaseUrl = $this->_config->getValue(self::XML_PATH_SECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
808  $secureFrontend = $this->_config->getValue(self::XML_PATH_SECURE_IN_FRONTEND, ScopeInterface::SCOPE_STORE);
809 
810  if (!$secureBaseUrl || !$secureFrontend) {
811  return false;
812  }
813 
814  $uri = UriFactory::factory($secureBaseUrl);
815  $port = $uri->getPort();
816  $serverPort = $this->_request->getServer('SERVER_PORT');
817  $isSecure = $uri->getScheme() == 'https' && isset($serverPort) && $port == $serverPort;
818  return $isSecure;
819  }
820 
821  /*************************************************************************************
822  * Store currency interface
823  */
824 
830  public function getBaseCurrencyCode()
831  {
832  $configValue = $this->getConfig(self::XML_PATH_PRICE_SCOPE);
833  if ($configValue == self::PRICE_SCOPE_GLOBAL) {
835  }
837  }
838 
844  public function getBaseCurrency()
845  {
846  $currency = $this->getData('base_currency');
847  if (null === $currency) {
848  $currency = $this->currencyFactory->create()->load($this->getBaseCurrencyCode());
849  $this->setData('base_currency', $currency);
850  }
851  return $currency;
852  }
853 
859  public function getDefaultCurrencyCode()
860  {
862  return $result;
863  }
864 
870  public function getDefaultCurrency()
871  {
872  $currency = $this->getData('default_currency');
873  if (null === $currency) {
874  $currency = $this->currencyFactory->create()->load($this->getDefaultCurrencyCode());
875  $this->setData('default_currency', $currency);
876  }
877  return $currency;
878  }
879 
886  public function setCurrentCurrencyCode($code)
887  {
888  $code = strtoupper($code);
889  if (in_array($code, $this->getAvailableCurrencyCodes())) {
890  $this->_getSession()->setCurrencyCode($code);
891 
892  $defaultCode = $this->_storeManager->getWebsite()->getDefaultStore()->getDefaultCurrency()->getCode();
893  $this->_httpContext->setValue(Context::CONTEXT_CURRENCY, $code, $defaultCode);
894  }
895  return $this;
896  }
897 
903  public function getCurrentCurrencyCode()
904  {
905  // try to get currently set code among allowed
906  $code = $this->_httpContext->getValue(Context::CONTEXT_CURRENCY);
907  $code = $code === null ? $this->_getSession()->getCurrencyCode() : $code;
908  if (empty($code)) {
909  $code = $this->getDefaultCurrencyCode();
910  }
911  if (in_array($code, $this->getAvailableCurrencyCodes(true))) {
912  return $code;
913  }
914 
915  // take first one of allowed codes
916  $codes = array_values($this->getAvailableCurrencyCodes(true));
917  if (empty($codes)) {
918  // return default code, if no codes specified at all
919  return $this->getDefaultCurrencyCode();
920  }
921  return array_shift($codes);
922  }
923 
933  public function getAvailableCurrencyCodes($skipBaseNotAllowed = false)
934  {
935  $codes = $this->getData('available_currency_codes');
936  if (null === $codes) {
937  $codes = explode(',', $this->getConfig(Currency::XML_PATH_CURRENCY_ALLOW));
938  // add base currency, if it is not in allowed currencies
939  $baseCurrencyCode = $this->getBaseCurrencyCode();
940  if (!in_array($baseCurrencyCode, $codes)) {
941  $codes[] = $baseCurrencyCode;
942 
943  // save base currency code index for further usage
944  $disallowedBaseCodeIndex = array_keys($codes);
945  $disallowedBaseCodeIndex = array_pop($disallowedBaseCodeIndex);
946  $this->setData('disallowed_base_currency_code_index', $disallowedBaseCodeIndex);
947  }
948  $this->setData('available_currency_codes', $codes);
949  }
950 
951  // remove base currency code, if it is not allowed by config (optional)
952  if ($skipBaseNotAllowed) {
953  $disallowedBaseCodeIndex = $this->getData('disallowed_base_currency_code_index');
954  if (null !== $disallowedBaseCodeIndex) {
955  unset($codes[$disallowedBaseCodeIndex]);
956  }
957  }
958  return $codes;
959  }
960 
966  public function getAllowedCurrencies()
967  {
968  return explode(',', $this->getConfig($this->_currencyInstalled));
969  }
970 
976  public function getCurrentCurrency()
977  {
978  $currency = $this->getData('current_currency');
979 
980  if ($currency === null) {
981  $currency = $this->currencyFactory->create()->load($this->getCurrentCurrencyCode());
982  $baseCurrency = $this->getBaseCurrency();
983 
984  if (!$baseCurrency->getRate($currency)) {
985  $currency = $baseCurrency;
986  $this->setCurrentCurrencyCode($baseCurrency->getCode());
987  }
988  $this->setData('current_currency', $currency);
989  }
990  return $currency;
991  }
992 
998  public function getCurrentCurrencyRate()
999  {
1000  return $this->getBaseCurrency()->getRate($this->getCurrentCurrency());
1001  }
1002 
1008  public function getRootCategoryId()
1009  {
1010  if (!$this->getGroup()) {
1012  }
1013  return $this->getGroup()->getRootCategoryId();
1014  }
1015 
1022  public function setGroup(Group $group)
1023  {
1024  $this->setGroupId($group->getId());
1025  return $this;
1026  }
1027 
1033  public function getGroup()
1034  {
1035  if (null === $this->getGroupId()) {
1036  return false;
1037  }
1038  return $this->groupRepository->get($this->getGroupId());
1039  }
1040 
1046  public function getWebsiteId()
1047  {
1048  return $this->_getData('website_id');
1049  }
1050 
1058  public function afterSave()
1059  {
1060  $this->_storeManager->reinitStores();
1061  if ($this->isObjectNew()) {
1062  $event = $this->_eventPrefix . '_add';
1063  } else {
1064  $event = $this->_eventPrefix . '_edit';
1065  }
1066  $store = $this;
1067  $this->getResource()->addCommitCallback(function () use ($event, $store) {
1068  $this->eventManager->dispatch($event, ['store' => $store]);
1069  });
1070  return parent::afterSave();
1071  }
1072 
1076  public function setWebsiteId($websiteId)
1077  {
1078  return $this->setData('website_id', $websiteId);
1079  }
1080 
1086  public function getGroupId()
1087  {
1088  return $this->_getData('group_id');
1089  }
1090 
1096  public function getStoreGroupId()
1097  {
1098  return $this->getGroupId();
1099  }
1100 
1105  {
1106  return $this->setGroupId($storeGroupId);
1107  }
1108 
1112  public function getIsActive()
1113  {
1114  return $this->_getData('is_active');
1115  }
1116 
1120  public function setIsActive($isActive)
1121  {
1122  return $this->setData('is_active', $isActive);
1123  }
1124 
1130  public function getDefaultGroupId()
1131  {
1132  return $this->_getData('default_group_id');
1133  }
1134 
1140  public function isCanDelete()
1141  {
1142  if (!$this->getId()) {
1143  return false;
1144  }
1145 
1146  return $this->getGroup()->getStoresCount() > 1;
1147  }
1148 
1155  public function isDefault()
1156  {
1157  if (!$this->getId() && $this->getWebsite() && $this->getWebsite()->getStoresCount() == 0) {
1158  return true;
1159  }
1160  return $this->getGroup()->getDefaultStoreId() == $this->getId();
1161  }
1162 
1171  public function getCurrentUrl($fromStore = true)
1172  {
1173  $sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession());
1174  $requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));
1175 
1176  $storeUrl = $this->getUrl('', ['_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]);
1177 
1178  if (!filter_var($storeUrl, FILTER_VALIDATE_URL)) {
1179  return $storeUrl;
1180  }
1181 
1182  $storeParsedUrl = parse_url($storeUrl);
1183 
1184  $storeParsedQuery = [];
1185  if (isset($storeParsedUrl['query'])) {
1186  parse_str($storeParsedUrl['query'], $storeParsedQuery);
1187  }
1188 
1189  $currQuery = $this->_request->getQueryValue();
1190  if (isset($currQuery[$sidQueryParam])
1191  && !empty($currQuery[$sidQueryParam])
1192  && $this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]
1193  ) {
1194  unset($currQuery[$sidQueryParam]);
1195  }
1196 
1197  foreach ($currQuery as $key => $value) {
1198  $storeParsedQuery[$key] = $value;
1199  }
1200 
1201  if (!$this->isUseStoreInUrl()) {
1202  $storeParsedQuery['___store'] = $this->getCode();
1203  }
1204 
1205  if ($fromStore !== false) {
1206  $storeParsedQuery['___from_store'] = $fromStore ===
1207  true ? $this->_storeManager->getStore()->getCode() : $fromStore;
1208  }
1209 
1210  $requestStringParts = explode('?', $requestString, 2);
1211  $requestStringPath = $requestStringParts[0];
1212  if (isset($requestStringParts[1])) {
1213  parse_str($requestStringParts[1], $requestString);
1214  } else {
1215  $requestString = [];
1216  }
1217 
1218  $currentUrlQueryParams = array_merge($requestString, $storeParsedQuery);
1219 
1220  $currentUrl = $storeParsedUrl['scheme']
1221  . '://'
1222  . $storeParsedUrl['host']
1223  . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
1224  . $storeParsedUrl['path']
1225  . $requestStringPath
1226  . ($currentUrlQueryParams ? '?' . http_build_query($currentUrlQueryParams) : '');
1227 
1228  return $currentUrl;
1229  }
1230 
1236  public function isActive()
1237  {
1238  return (bool)$this->_getData('is_active');
1239  }
1240 
1246  public function beforeDelete()
1247  {
1248  $this->_configDataResource->clearScopeData(ScopeInterface::SCOPE_STORES, $this->getId());
1249  return parent::beforeDelete();
1250  }
1251 
1257  public function afterDelete()
1258  {
1259  $store = $this;
1260  $this->getResource()->addCommitCallback(function () use ($store) {
1261  $this->_storeManager->reinitStores();
1262  $this->eventManager->dispatch($this->_eventPrefix . '_delete', ['store' => $store]);
1263  });
1264  parent::afterDelete();
1265  $this->_configCacheType->clean();
1266 
1267  if ($this->getId() === $this->getGroup()->getDefaultStoreId()) {
1268  $ids = $this->getGroup()->getStoreIds();
1269  if (!empty($ids) && count($ids) > 1) {
1270  unset($ids[$this->getId()]);
1271  $defaultId = current($ids);
1272  } else {
1273  $defaultId = null;
1274  }
1275  $this->getGroup()->setDefaultStoreId($defaultId);
1276  $this->getGroup()->save();
1277  }
1278 
1279  return $this;
1280  }
1281 
1287  public function resetConfig()
1288  {
1289  $this->_config->reinit();
1290  $this->_dirCache = [];
1291  $this->_baseUrlCache = [];
1292  $this->_urlCache = [];
1293 
1294  return $this;
1295  }
1296 
1303  public function isReadOnly($value = null)
1304  {
1305  if (null !== $value) {
1306  $this->_isReadOnly = (bool)$value;
1307  }
1308  return $this->_isReadOnly;
1309  }
1310 
1316  public function getFrontendName()
1317  {
1318  if (null === $this->_frontendName) {
1319  $storeGroupName = (string)$this->_config
1321  $this->_frontendName = !empty($storeGroupName) ? $storeGroupName : $this->getGroup()->getName();
1322  }
1323  return $this->_frontendName;
1324  }
1325 
1331  public function getFormattedAddress()
1332  {
1333  return $this->information->getFormattedAddress($this);
1334  }
1335 
1341  public function getIdentities()
1342  {
1343  return [self::CACHE_TAG];
1344  }
1345 
1349  public function getStorePath()
1350  {
1351  $parsedUrl = parse_url($this->getBaseUrl());
1352  return isset($parsedUrl['path']) ? $parsedUrl['path'] : '/';
1353  }
1354 
1359  public function getScopeType()
1360  {
1362  }
1363 
1368  public function getScopeTypeName()
1369  {
1370  return 'Store View';
1371  }
1372 
1376  public function getExtensionAttributes()
1377  {
1378  return $this->_getExtensionAttributes();
1379  }
1380 
1385  public function setExtensionAttributes(
1386  \Magento\Store\Api\Data\StoreExtensionInterface $extensionAttributes
1387  ) {
1388  return $this->_setExtensionAttributes($extensionAttributes);
1389  }
1390 
1397  private function getUrlModifier()
1398  {
1399  if ($this->urlModifier === null) {
1400  $this->urlModifier = \Magento\Framework\App\ObjectManager::getInstance()->get(
1401  \Magento\Framework\Url\ModifierInterface::class
1402  );
1403  }
1404 
1405  return $this->urlModifier;
1406  }
1407 }
setGroup(Group $group)
Definition: Store.php:1022
const XML_PATH_UNSECURE_BASE_STATIC_URL
Definition: Store.php:84
const XML_PATH_UNSECURE_BASE_URL
Definition: Store.php:66
const XML_PATH_SECURE_BASE_MEDIA_URL
Definition: Store.php:86
const CUSTOM_ENTRY_POINT_PARAM
Definition: Store.php:57
$config
Definition: fraud_order.php:17
const XML_PATH_UNSECURE_BASE_MEDIA_URL
Definition: Store.php:88
setWebsiteId($websiteId)
Definition: Store.php:1076
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
setStoreGroupId($storeGroupId)
Definition: Store.php:1104
$group
Definition: sections.phtml:16
$storeManager
isReadOnly($value=null)
Definition: Store.php:1303
__()
Definition: __.php:13
$resource
Definition: bulk.php:12
getCurrentUrl($fromStore=true)
Definition: Store.php:1171
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\ResourceModel\Store $resource, \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase, \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Framework\UrlInterface $url, \Magento\Framework\App\RequestInterface $request, \Magento\Config\Model\ResourceModel\Config\Data $configDataResource, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\App\Config\ReinitableConfigInterface $config, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Session\SidResolverInterface $sidResolver, \Magento\Framework\App\Http\Context $httpContext, \Magento\Framework\Session\SessionManagerInterface $session, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Store\Model\Information $information, $currencyInstalled, \Magento\Store\Api\GroupRepositoryInterface $groupRepository, \Magento\Store\Api\WebsiteRepositoryInterface $websiteRepository, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, $isCustomEntryPoint=false, array $data=[], \Magento\Framework\Event\ManagerInterface $eventManager=null)
Definition: Store.php:357
load($key, $field=null)
Definition: Store.php:496
setCurrentCurrencyCode($code)
Definition: Store.php:886
$type
Definition: item.phtml:13
setExtensionAttributes(\Magento\Store\Api\Data\StoreExtensionInterface $extensionAttributes)
Definition: Store.php:1385
const XML_PATH_SECURE_BASE_LINK_URL
Definition: Store.php:78
$value
Definition: gender.phtml:16
_getMediaScriptUrl(Filesystem $filesystem, $secure)
Definition: Store.php:730
const XML_PATH_UNSECURE_BASE_LINK_URL
Definition: Store.php:80
const XML_PATH_ENABLE_UPGRADE_INSECURE
Definition: Store.php:76
const XML_PATH_SECURE_IN_FRONTEND
Definition: Store.php:70
setIsActive($isActive)
Definition: Store.php:1120
const XML_PATH_SECURE_BASE_URL
Definition: Store.php:68
setWebsite(Website $website)
Definition: Store.php:560
getAvailableCurrencyCodes($skipBaseNotAllowed=false)
Definition: Store.php:933
$properties
Definition: categories.php:26
getBaseUrl($type=UrlInterface::URL_TYPE_LINK, $secure=null)
Definition: Store.php:607
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
const XML_PATH_SECURE_BASE_STATIC_URL
Definition: Store.php:82
const XML_PATH_SECURE_IN_ADMINHTML
Definition: Store.php:72
$code
Definition: info.phtml:12
if(!isset($_GET['name'])) $name
Definition: log.php:14