Skip to content

Commit 65a17c6

Browse files
authored
Merge pull request #8 from Taintedmedialtd/master
Now works for multi-website setups per default store
2 parents 3af62ed + fba9596 commit 65a17c6

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

Plugin/Model/HideDefaultStoreCode.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ class HideDefaultStoreCode
66
{
77
/**
88
*
9-
* @var \Noon\HideDefaultStoreCode\Helper\Data
9+
* @var \Noon\HideDefaultStoreCode\Helper\Data
1010
*/
1111
protected $helper;
12-
12+
1313
/**
1414
*
1515
* @var \Magento\Store\Model\StoreManagerInterface
1616
*/
1717
protected $storeManager;
18-
18+
1919
/**
20-
*
20+
*
2121
* @param \Noon\HideDefaultStoreCode\Helper\Data $helper
2222
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
2323
*/
@@ -30,16 +30,21 @@ public function __construct(
3030
}
3131

3232
/**
33-
*
33+
*
3434
* @param \Magento\Store\Model\Store $subject
3535
* @param string $url
3636
* @return string
3737
*/
38-
public function afterGetBaseUrl(\Magento\Store\Model\Store $subject, $url)
39-
{
40-
if ($this->helper->isHideDefaultStoreCode() && !is_null($this->storeManager->getDefaultStoreView())) {
41-
$url = str_replace('/'.$this->storeManager->getDefaultStoreView()->getCode().'/', '/', $url);
42-
}
43-
return $url;
44-
}
45-
}
38+
public function afterGetBaseUrl(\Magento\Store\Model\Store $subject, $url)
39+
{
40+
$websiteId = $this->storeManager->getStore()->getWebsiteId();
41+
$defaultStore = $this->storeManager->getWebsite($websiteId)->getDefaultStore();
42+
if (
43+
$this->helper->isHideDefaultStoreCode()
44+
&& !is_null($defaultStore)
45+
) {
46+
$url = str_replace('/'.$defaultStore->getCode().'/', '/', $url);
47+
}
48+
return $url;
49+
}
50+
}

0 commit comments

Comments
 (0)