Skip to content

Commit ecf27be

Browse files
committed
#12206: Tracking link returns 404 page in admin panel
1 parent b1cc3ea commit ecf27be

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

app/code/Magento/Shipping/Helper/Data.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
*/
1212
namespace Magento\Shipping\Helper;
1313

14+
use Magento\Framework\App\ObjectManager;
15+
use Magento\Framework\UrlInterface;
16+
use Magento\Store\Model\StoreManagerInterface;
17+
1418
class Data extends \Magento\Framework\App\Helper\AbstractHelper
1519
{
1620
/**
@@ -21,19 +25,28 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
2125
protected $_allowedHashKeys = ['ship_id', 'order_id', 'track_id'];
2226

2327
/**
24-
* @var \Magento\Store\Model\StoreManagerInterface
28+
* @var StoreManagerInterface
2529
*/
2630
protected $_storeManager;
2731

32+
/**
33+
* @var UrlInterface|null
34+
*/
35+
private $url;
36+
2837
/**
2938
* @param \Magento\Framework\App\Helper\Context $context
30-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
39+
* @param StoreManagerInterface $storeManager
40+
* @param UrlInterface|null $url
3141
*/
3242
public function __construct(
3343
\Magento\Framework\App\Helper\Context $context,
34-
\Magento\Store\Model\StoreManagerInterface $storeManager
44+
StoreManagerInterface $storeManager,
45+
UrlInterface $url = null
3546
) {
3647
$this->_storeManager = $storeManager;
48+
$this->url = $url ?: ObjectManager::getInstance()->get(UrlInterface::class);
49+
3750
parent::__construct($context);
3851
}
3952

@@ -64,12 +77,13 @@ protected function _getTrackingUrl($key, $model, $method = 'getId')
6477
{
6578
$urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}";
6679
$params = [
80+
'_scope' => $model->getStoreId(),
81+
'_nosid' => true,
6782
'_direct' => 'shipping/tracking/popup',
6883
'_query' => ['hash' => $this->urlEncoder->encode($urlPart)]
6984
];
7085

71-
$storeModel = $this->_storeManager->getStore($model->getStoreId());
72-
return $storeModel->getUrl('', $params);
86+
return $this->url->getUrl('', $params);
7387
}
7488

7589
/**

app/code/Magento/Shipping/etc/adminhtml/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\Shipping\Model\Shipping" type="Magento\Shipping\Model\Shipping\Labels" />
10+
11+
<type name="Magento\Shipping\Helper\Data">
12+
<arguments>
13+
<!-- Use frontend URL model-->
14+
<argument name="url" xsi:type="object">Magento\Framework\Url</argument>
15+
</arguments>
16+
</type>
1017
</config>

0 commit comments

Comments
 (0)