Magento 2 get Backend Url

0
202
Magento 2 get Backend Url

In this article, you going see discussion regarding Magento 2 get Backend Url in a detail and step by step with code snippet.

If you are looking for this topic then you are at right place.

Let’s start with the topic of Magento 2 get Backend Url

Use module Url Class to get backend Url.

public function __construct(
    \Magento\Backend\Model\Url $backendUrlManager
) {
    $this->backendUrlManager  = $backendUrlManager;
}
public function getBackendUrl()
{
    return $this->backendUrlManager->getUrl('sales/order/view', ['param1' => 'param1']);
}

Use some action Sales/order/view action with a query string as param1 in URL

Then use below code template file to get backend-Url.

echo $this->getBackendUrl();

Magento 2 Get Base Url and Current Url – Complete Guide

Conclusion :

Use the above code to get backend Url.

I hope you like this article and if you think that i have missing something, please comment below.