Skip to content

Commit de78c7f

Browse files
committed
Fix issue #2 - Redirect to base url
1 parent 5d3ba5a commit de78c7f

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Plugin/Model/BaseUrlChecker.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © OpenGento, All rights reserved.
4+
* See LICENSE bundled with this library for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Opengento\StorePathUrl\Plugin\Model;
9+
10+
use Magento\Framework\App\Request\Http;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Store\Model\BaseUrlChecker as Subject;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
15+
use function parse_url;
16+
17+
class BaseUrlChecker
18+
{
19+
public function __construct(private StoreManagerInterface $storeManager) {}
20+
21+
/**
22+
* @throws NoSuchEntityException
23+
*/
24+
public function beforeExecute(Subject $subject, array $uri, Http $request): array
25+
{
26+
return [parse_url($this->storeManager->getStore()->getBaseUrl()), $request];
27+
}
28+
}

etc/frontend/di.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © OpenGento, All rights reserved.
5+
* See LICENSE bundled with this library for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\Store\Model\BaseUrlChecker">
10+
<plugin name="Opengento_StorePathUrl::set_base_url_type_link_for_redirect" type="Opengento\StorePathUrl\Plugin\Model\BaseUrlChecker"/>
11+
</type>
12+
</config>

0 commit comments

Comments
 (0)