20 const HINT_URL =
'http://docs.magento.com/m2/ce/user_guide/configuration/scope.html';
65 protected $_template =
'Magento_Backend::store/switcher.phtml';
97 \
Magento\Store\Model\WebsiteFactory $websiteFactory,
98 \
Magento\Store\Model\GroupFactory $storeGroupFactory,
99 \
Magento\Store\Model\StoreFactory $storeFactory,
102 parent::__construct($context,
$data);
103 $this->_websiteFactory = $websiteFactory;
104 $this->_storeGroupFactory = $storeGroupFactory;
105 $this->_storeFactory = $storeFactory;
113 parent::_construct();
115 $this->setUseConfirm(
true);
116 $this->setUseAjax(
true);
118 $this->setShowManageStoresLink(0);
120 if (!$this->
hasData(
'switch_websites')) {
121 $this->setSwitchWebsites(
false);
123 if (!$this->
hasData(
'switch_store_groups')) {
124 $this->setSwitchStoreGroups(
false);
126 if (!$this->
hasData(
'switch_store_views')) {
127 $this->setSwitchStoreViews(
true);
129 $this->setDefaultSelectionName(
__(
'All Store Views'));
137 $collection = $this->_websiteFactory->create()->getResourceCollection();
154 $websites = $this->_storeManager->getWebsites();
168 return (
bool)$this->
getData(
'switch_websites');
177 $this->
setData(
'website_var_name', $varName);
186 if ($this->
hasData(
'website_var_name')) {
187 return (
string)$this->
getData(
'website_var_name');
207 if (!$this->
hasData(
'website_id')) {
210 return $this->
getData(
'website_id');
222 return $website->getGroupCollection();
246 return (
bool)$this->
getData(
'switch_store_groups');
255 $this->
setData(
'store_group_var_name', $varName);
264 if ($this->
hasData(
'store_group_var_name')) {
265 return (
string)$this->
getData(
'store_group_var_name');
285 if (!$this->
hasData(
'store_group_id')) {
288 return $this->
getData(
'store_group_id');
298 $group = $this->_storeGroupFactory->create()->load(
$group);
322 if (!in_array(
$storeId, $storeIds)) {
335 if (!$this->
hasData(
'store_id')) {
338 return $this->
getData(
'store_id');
357 return (
bool)$this->
getData(
'switch_store_views');
366 $this->
setData(
'store_var_name', $varName);
375 if ($this->
hasData(
'store_var_name')) {
376 return (
string)$this->
getData(
'store_var_name');
419 $name = $this->getDefaultSelectionName();
434 $website = $this->_websiteFactory->create();
450 $group = $this->_storeGroupFactory->create();
466 $store = $this->_storeFactory->create();
480 $this->_storeIds = $storeIds;
497 return !$this->_storeManager->isSingleStoreMode();
506 return parent::_toHtml();
519 if (
null !== $hasDefaultOption) {
520 $this->_hasDefaultOption = $hasDefaultOption;
545 $html =
'<div class="admin__field-tooltip tooltip">' .
'<a' .
' href="' . $this->
escapeUrl(
547 ) .
'"' .
' onclick="this.target=\'_blank\'"' .
' title="' .
__(
549 ) .
'"' .
' class="admin__field-tooltip-action action-help"><span>' .
__(
551 ) .
'</span></a></span>' .
' </div>';
563 if ($this->
hasData(
'is_using_iframe')) {
564 return (
bool)$this->
getData(
'is_using_iframe');
setWebsiteVarName($varName)
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Store\Model\GroupFactory $storeGroupFactory, \Magento\Store\Model\StoreFactory $storeFactory, array $data=[])
getData($key='', $index=null)
setStoreGroupVarName($varName)
isStoreGroupSwitchEnabled()
isWebsiteSelected(\Magento\Store\Model\Website $website)
getCurrentStoreGroupName()
isStoreGroupSelected(\Magento\Store\Model\Group $group)
isStoreSelected(\Magento\Store\Model\Store $store)
getUrl($route='', $params=[])
setData($key, $value=null)
getCurrentSelectionName()
getStoreCollection($group)
hasDefaultOption($hasDefaultOption=null)
$_defaultStoreGroupVarName
getGroupCollection($website)
setStoreVarName($varName)
if(!isset($_GET['name'])) $name