0

I use the below code to get admin url of given frontName/controllerName/Action

protected $storeManagerInterface;

public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManagerInterface) 
{         
    $this->storeManagerInterface = $storeManagerInterface;
}
public function getAdminUrl() 
{   
    $store = $this->storeManagerInterface->getStore();
    return $store->getUrl('emailquotepro/emailquote/create');       
}

but it return wrong value

http://host/emailquotepro/emailquote/create/

I expect the url something like

https://host/admin/emailquotepro/emailquote/create/key/786fd58929a16a83d67cdf0aae51c55cdfb7afdb8f8a124b51deeda3cbc4c9a5/

I check the areacode, it's already set as adminhtml.

If you have any prediction, please let me know.

Thanks.

2
  • Can u please share ur admin and frontend route.xml
    – Amit Bera
    Jan 24, 2018 at 14:39
  • Type in command to get the admin URL php bin/magento info:adminuri Jul 13, 2019 at 11:05

2 Answers 2

1

You can admin module us by below code

\Magento\Backend\Helper\Data $backenHelper

use

$backenHelper->getUrl('emailquotepro/emailquote/create')

0

Type in command to get the admin URL

php bin/magento info:adminuri

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.