-
Notifications
You must be signed in to change notification settings - Fork 0
/
Switcher.php
49 lines (48 loc) · 1.89 KB
/
Switcher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Frugue\Store;
use Magento\Framework\App\ActionInterface as IAction;
use Magento\Framework\App\Response\RedirectInterface as IRedirect;
use Magento\Store\Model\StoreManagerInterface as IStoreManager;
// 2020-01-18
final class Switcher {
/**
* 2020-01-18
* @used-by \Frugue\Shipping\Header::_toHtml()
* @used-by \Frugue\Store\Block\Switcher::post()
* @used-by \Frugue\Store\Plugin\Framework\App\FrontControllerInterface::aroundDispatch()
*/
const PATH = 'stores/store/switch';
/**
* 2020-01-18
* @used-by \Frugue\Shipping\Header::_toHtml()
* @used-by \Frugue\Store\Block\Switcher::post()
* @used-by \Frugue\Store\Plugin\Framework\App\FrontControllerInterface::aroundDispatch()
* @param string $toStore
* @return array(string => string)
*/
static function params($toStore) {return df_url_param_redirect(df_replace_store_code_in_url($toStore)) + [
IStoreManager::PARAM_NAME => $toStore
/**
* 2020-01-18
* 1) "The store/country switcher at the frontend's header does not work":
* https://github.com/frugue/store/issues/1
* 2) @see \Magento\Store\Controller\Store\SwitchAction::execute():
* $fromStoreCode = $this->_request->getParam('___from_store');
* $requestedUrlToRedirect = $this->_redirect->getRedirectUrl();
* $redirectUrl = $requestedUrlToRedirect;
* $error = null;
* try {
* $fromStore = $this->storeRepository->get($fromStoreCode);
* $targetStore = $this->storeRepository->getActiveStoreByCode($targetStoreCode);
* }
* catch (StoreIsInactiveException $e) {
* $error = __('Requested store is inactive');
* }
* catch (NoSuchEntityException $e) {
* $error = __("The store that was requested wasn't found. Verify the store and try again.");
* }
* https://github.com/magento/magento2/blob/2.3.0/app/code/Magento/Store/Controller/Store/SwitchAction.php#L95-L113
*/
,'___from_store' => df_store_code()
];}
}