We are already know that How to get Admin page url in magento1 from this question How to get Admin page url?

But how to get it at magento 2?


If want to get admin URL to Magento 2 then your can try below Solution

In order to get admin URL ,you need to inject the Magento_Backend ‘s helper class Magento\Backend\Helper\Data to __construct() function.

 * @var Magento\Backend\Helper\Data
protected $HelperBackend;

public function __construct(
\Magento\Backend\Helper\Data $HelperBackend
) {
$this->HelperBackend = $HelperBackend;

 * @param \Magento\Framework\Event\Observer $observer
 * @return void
public function getAdminUrl()
echo $this->HelperBackend->getHomePageUrl();
  • In their latest release, i.e, Magento 2.2.0, I've noticed that they have deprecated the \Magento\Backend\Helper\Data class. So I'm assuming there's another way to do it? – Jay Ghosh Oct 31 '17 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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