我想使用此代碼重定向到前端網址,但它總是重定向到管理儀表板。我搜索並嘗試了很多演示代碼,但我無法實現它的工作。我假設所有屬性都設置正確。Magento 2無法從管理控制器重定向到前端
$url= $this->_storeManager->getStore(1)->getUrl('storelocator/index/index');
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setUrl($url);
return $resultRedirect;
爲你打破不要使用直接對象管理器調用DI概念。 – Luke